Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Fix #1881, Ticks are now visible for filled contours without grid=:none parameter #2809

Closed

Conversation

LakshyaKhatri
Copy link
Contributor

Fixes #1881

I discussed this issue with @isentropic and he suggested to add a zorder argument in the below call:

axis."set_tick_params"(;which="both", kw...)

I tried adding zorder with a high value in other places too but it didn't work.

Turned out the axes were drawn below the countors when grid was set to true:

if axis[:grid] && !(ticks in (:none, nothing, false))
fgcolor = py_color(axis[:foreground_color_grid])
pyaxis."grid"(true,
color = fgcolor,
linestyle = py_linestyle(:line, axis[:gridstyle]),
linewidth = py_thickness_scale(plt, axis[:gridlinewidth]),
alpha = axis[:gridalpha])
ax."set_axisbelow"(true)

and hence the ticks were also hiding:
fig

Removing this line:

ax."set_axisbelow"(true)

or setting ax."set_axisbelow"(true) to false is producing the following results:
Figure_1

If this is the right solution, I will update the same for other backends too.

@BeastyBlacksmith
Copy link
Member

The question is, whether we want to show gridlines on top also or not?

@daschw
Copy link
Member

daschw commented Jun 23, 2020

We don't do it for the other backends, right?

@BeastyBlacksmith
Copy link
Member

I think pgfplotsx does so, too. I planned to change that though... however I think it would be nice to be able to enable them, if they are wanted. So basically it would be nice, if we could have different defaults per seriestype.

@LakshyaKhatri
Copy link
Contributor Author

So, the defaults should not contain gridlines or the other way around?

@BeastyBlacksmith
Copy link
Member

I think for this PR gridlines should either not be displayed or drawn behind the contour.

@isentropic
Copy link
Member

I think gridlines should be behind the contour but ticks on top

@LakshyaKhatri
Copy link
Contributor Author

LakshyaKhatri commented Jun 23, 2020

Yes, I am working on the required changes. Tweaking zorder is giving unexpected results.

@LakshyaKhatri
Copy link
Contributor Author

LakshyaKhatri commented Jun 23, 2020

I think for this PR gridlines should either not be displayed or drawn behind the contour.

I tried almost everything, but the latter case doesn't seem to work. The best solution I found till now is this thread from matplotlib forum (which didn't work). Another solution can be showing the ticks on the "out" direction by default.

@LakshyaKhatri
Copy link
Contributor Author

LakshyaKhatri commented Jun 30, 2020

I discussed this issue with the maintainer of Matplotlib and he has suggested solutions in this thread. Kindly look into the discussion and I think then we can decide what will be the best solution 😄

@BeastyBlacksmith
Copy link
Member

I would probably go with disabling the normal ticks and then draw ticks with the secondary axis feature.
But in the end it comes down to what works best for you.

@LakshyaKhatri
Copy link
Contributor Author

LakshyaKhatri commented Jun 30, 2020

Okay, the secondary axis works:
Figure_2

but the issue is, it makes all the axis operations dependent on the secondary axis. It also increases the complexity by giving us different handles for each secondary axis (in this case two different handels for bottom and left axis).

@BeastyBlacksmith
Copy link
Member

It does increase the complexity, but if we can keep that isolated to the part where axis decorations are built it's worth the flexibility we gain, IMO.
Would be good, if you push the changes, so we can have a look at the code.
Also interested about @isentropic's opinion.

@isentropic
Copy link
Member

I think we should not overcomplicate things with secondary axis and stuff make that issue closed due to matplotlib limitations and thats it.

If we have secondary axis that might overcomplicate things a lot. Because:

1 Plots calculates the ticks
2 series are drawn on axes, so if we have image with scatter on top, they should be drawn on different axes, which in turn would ruin the order. I guess drawing scatter on top of image wouldn't work (or the other way)
3 This would absolutely make no sense for future maintainers that will work with the codebase. I'm very sure that this would cause problem in understanding imshow and fixing future issues associated with it, and eventually someone will clear it up and make as it is now.

I understand that this issue had turned to be way more complex than it should have been, but I really think that fixing this is not worth our efforts.

You have done a great job @LakshyaKhatri I can only say that it is sad that such a thoroughly researched issue happens not to have a simple solution.

@LakshyaKhatri
Copy link
Contributor Author

Thanks @isentropic for the appreciation. I'll keep contributing to the Julia community. Feel free to close this PR 😄

@BeastyBlacksmith
Copy link
Member

Hmm... disabling the gridlines is still an option

@LakshyaKhatri
Copy link
Contributor Author

LakshyaKhatri commented Jul 1, 2020

Yes, that will be an easy hack. Let me know if you are up to this. I will push the changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ticks of contour plots with PyPlot
4 participants