JuliaPlots / Plots.jl

Powerful convenience for Julia visualizations and data analysis
https://docs.juliaplots.org
Other
1.84k stars 354 forks source link

Ticks of contour plots with PyPlot #1881

Open y-nkt opened 5 years ago

y-nkt commented 5 years ago

I found a strange behavior on ticks of contour plot with PyPlots.

Default setting does not make ticks:

using Plots; pyplot()
contour(-2:0.1:2,-2:0.1:2,(x,y)->x^2+y^2, fill=true, levels=50)

contour1

If I put a grid option, I get ticks:

using Plots; pyplot()
contour(-2:0.1:2,-2:0.1:2,(x,y)->x^2+y^2, fill=true, levels=50, grid=:none)

contour2

It seems better to use the second case as default. Thank you for your development.

Julia Version 1.0.3 Plots v0.22.3 PyPlot v2.6.3

isentropic commented 4 years ago

Ticks are there if you zoom out. Somehow the image gets drawn on top of ticks image

ashwani-rathee commented 4 years ago

Hey @BeastyBlacksmith ,is this issue still open and something to work upon??

BeastyBlacksmith commented 4 years ago

Yes, that is correct

ashwani-rathee commented 4 years ago

@BeastyBlacksmith It should show full ticks and zoom out like suggested in the pic given by @isentropic?? ..or it should show ticks even in the graph as shown by @y-nkt without even using grid??

isentropic commented 4 years ago

ticks should be present without the grid option

isentropic commented 4 years ago

the zoomed out plot meant to show that ticks are drawn, but mistakenly end-up laying behind the plot

isentropic commented 4 years ago

@ashwani-rathee there is no need to ask if any issues are worked upon, issues are always updated. So, if you see an open issue there is a 99% chance that it has not been attempted to be fixed unless there exists a PR linking to that issue

LakshyaKhatri commented 4 years ago

Hello @isentropic, I looked into the codebase and tried to understand it. Do I have to edit each backend file separately? Please let me know if I am doing the right thing or not. Kindly provide any pointers if I am going in the wrong direction.

isentropic commented 4 years ago

Yes I believe, this should be handled for all backends, perhaps some backends handle this already.

In pyplot, this issue would be solved by looking into zorder of axis ticks or this

isentropic commented 4 years ago

The issue with pyplot is that, layer order of axis ticks is below the layer of contour. This way contour ends up above the ticks. Perhaps this line is what yuo are looking for https://github.com/JuliaPlots/Plots.jl/blob/47590b2538b9d0387b14d46eb49e7257f904dde6/src/backends/pyplot.jl#L850