Change distance between dots in `linestyle=:dot` plotting option

I am plotting something like:

plot(x->x^2,lw=5,linestyle=:dot)

image

Is there some way to modify the distance between the individual dots in the plot?

1 Like

A ridiculous workaround to make it denser:

using Plots; gr()
x1, x2, dx = -2, 2, 0.1
plot(x->x^2, x1:dx:x2, c=:blue, lw=3, ls=:dot)
d = (x2 - x1)/55 / 5.5  # fudge factor (depends on line width)
plot!(x->x^2, (x1 + d):dx:(x2 + d), c=:blue, lw=3, ls=:dot)

2 Likes

One option is to reduce the line width, since the smaller dots will be packed in more tightly.

Do you mind posting a full example? I get a slightly different result when I run your code:
plot

I have the same problem (for dots as well as for dashes). Is there no parameter to adjust the space between dots/dashes? Basically :dot generates a line with dots with no space at all for me. Adjusting the linewidth does also affect the dot spacing, but (of course) dots become larger too which is not what I want.

Thanks in advance!

Not sure abouts Plots but with Makie you can pass a vector of lenghts as linestyles, see lines · Makie

1 Like

The short answer is: no, noone implemented this yet. Someday someone might have enough need to do it, but that day isn’t today.

Although with Add extra series options at the end by BeastyBlacksmith · Pull Request #4765 · JuliaPlots/Plots.jl · GitHub it can be set via extra keywords for the pgfplotsx backend.

1 Like

Thanks!