Plots.jl
Plots.jl copied to clipboard
Change plot border width
Hi guys!
Is there a way to change the border width of a plot? In PyPlot, I usually do:
blw = 2.5
ax[:spines]["top"][:set_linewidth](blw)
ax[:spines]["bottom"][:set_linewidth](blw)
ax[:spines]["left"][:set_linewidth](blw)
ax[:spines]["right"][:set_linewidth](blw)
Unfortunately, I think currently there is not.
This would require a new axis attribute like border_width
or axis_width
that would have to be implemented for all different backends (for pyplot exactly the way you showed above.
If anyone is up for that: border_alpha
, border_color
and maybe border_style
(:solid
/ :dash
/ :dot
/ ...) could be implemented simultaneously.
Hi @daschw ,
Thanks for the answer! As a workaround, is there a way to directly access the axes in PyPlot backend so that I can manually run those commands?
Some people have had luck modifying the o
field (the Python object) but that is thoroughly undefined. I think as a general rule, Plots is best for intuitive, one-line plotting, whereas for control-every-little-element-plotting it's much better to use PyPlot directly.
I'd not be so keen on adding heaps of new attributes to control the border attributes in detail.
Ok @mkborregaard , thanks for the answer. I have already tried to modify the o
field directly without success. I think I will have to stick with PyPlot instead.
I tried modifying the o
field and it can work.
plt = plot(rand(10))
fig = plt.o
ax = fig[:get_axes]()[1]
ax[:spines]["left"][:set_linewidth](20)
PyPlot.draw()
I basically got this from #288 however they do mention that savefig()
resets any changes... So I guess as @mkborregaard said it's probably better to use PyPlot directly :(
Hi @apalugniok ,
I was using something similar to what you said. However, the next step was savefig
. This explains why I was not seeing the modifications.
I switched back to PyPlot as per @mkborregaard advice. I think this issue can be closed, right?
Let's keep it open.
A hacky way to achieve this in Plots could probably be to plot with framestyle = :none
and then just draw the axis lines manually like you want them to look.
Any update on this?
I am using PGFPlotsX and have the same problem with the plot and legend borders. They are too thick.
I'm using GR, and it would be super useful to be able to change the axis width for production ready plots
Gonna give my +1, this is something I'd really like.