Changing grid in Plots.jl?

Hello!

Basically I have something like this:

I want to make it into something like this, where the grey grid lines (so I want them removed as well) are replaced with the black ones I drew in paint:

Whenever I search “grid” on Google in connection with Julia it tells me about subplots etc. so I struggle a bit with finding the correct wording to do as I want.

Kind regards

This works:

julia> plot(0:0.1:1, 0:0.1:1, xticks=[0,0.5,1], yticks=[0,0.5,1])

also have a look through these attributes:
http://docs.juliaplots.org/latest/generated/attributes_axis/
searching for “ticks” and “grid”.

Thanks for your simple solution, for now this is fine, but in the future it could be nice to have it as that, but keeping the axes.

Thanks for the link.

Kind regards

Indeed, it might be nice to have that feature added to Plots.jl. I suggest you open a new “issue” for your feature request in the Plots.jl repository:
–> https://github.com/JuliaPlots/Plots.jl/issues

Otherwise, the dev team may never add it to their “todo list”.

(Temporary?) alternative:

In cases like this, you might want to look into tweaking the generated plot using backend-specific API. I am not familiar with all backends, but I can show an example with the InspectDR.jl backend (https://github.com/ma-laforge/InspectDR.jl):

using InspectDR
using Plots
using Colors
inspectdr()

plot(-1.4:0.1:1.4, -1.4:0.1:1.4)
pobj = gui() #Reference to InspectDR plot
splot = pobj.src.subplots[1] #Ref to subplot

#Add H/V markers @ origin:
black = RGB24(0, 0, 0)
markerline = line(color=black, style=:solid, width=3)
add(splot, hmarker(0, markerline))
add(splot, vmarker(0, markerline))
_frame = splot.layout[:frame_data]
    _frame.line = markerline #Match line from H/V markers
    splot.layout[:frame_data] = _frame #Must assign this way to "apply"

#Overwrite font because Plots.jl default font ("sans-serif") no longer
#properly supports UTF8 characters in newer Gtk distributions:
InspectDR.overwritefont!(splot.layout, fontname="Cambria")
InspectDR.refresh(pobj)

Note that the origin and grid lines will always display as desired, even if you pan/zoom in/out of the plot (ex: using ctrl+mousewheel or RMB+box-zoom)

Adding InspectDR

Note: you will have to install/add InspectDR to your Julia environment to get this to work:

] add InspectDR

Alternative 2

Another alternative is, of course, to directly use the backend that best suits your needs in cases where the Plots.jl module cannot achieve what you are looking to do.

Don’t forget: you can still make a feature request by opening an “issue” in Plots.jl for the next time! Who knows? you might end up implementing the feature yourself!

Thanks for your lengthy answer.

Nice to see that InspectDR can handle this case.

I might suggest it later on Github, but I would rather have them focus on other stuff. This was a bit of an edge case for me.

Kind regards