Constant dash density in Plots.jl

Hi,

I have a plot where I want to display some dash. But as the density of points increases, the dashes merge and become a straight line. This can be seen on the left of the plot near x=0.02.

Does anybody knows how to avoid this behavior?

Thank you for your help,

Use something like Interpolations.jl and sample your functions at regular intervals?

2 Likes

Indeed, if there is no built in solution in Plots, that would be a good way!

Thank you

Which Plots backend are you using? Shouldn’t happen with gr():

using GR
x = 1:100
setlinetype(2)
plot(log.(x),x)

It is GR…here is a MWE:

N = 5
x = 1:(2N)
ls = vcat([:solid for _=1:N], [:dash for _=1:N])
plot(log.(x),x; linestyle = ls)

N = 5:

N=50

Note that I am using broadcasting of arguments as in this discourse post

Unfortunately I still cannot see where the problem is in GR, especially since PyPlot and PlotlyJS give exactly the same results …

What should the plot look like after repeated overdrawing?

Do you probably want the internal dash offset be the same?

I want the dash to be visible, constant density is maybe asking too much

1 Like

This would mean drawing the dash pattern with the line and the (window) background color. In GR this is theoretically possible, but only via an internal (software) emulation.

Is this really what you want, or did I misunderstand the purpose?

I can reformulate to be sure. It is linked to this post.

I want to be able to draw curves and specify, with an argument, the linestyle of the points so as to be able to control which parts of the curve are continuous and which are dash. Additionally, I want the dashed part to be visible irrespective of the underlying point density.

Ok - I understand. But, IMO that’s a functionality that should be provided/implemented in Plots.jl - not in the backend code. The main reason is, that most underlying (low-level) systems would not support multiple line attributes within a path.

I agree. Note that I did not ask specifically for a GR solution. Thank you for your help