-
-
Notifications
You must be signed in to change notification settings - Fork 358
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Customize errorbars (in particular their caps) #2156
Comments
errorbar caps are controlled by the |
But |
You have another option of setting |
Another thing that, as far as I know, is not possible it to change the vertical thickness of the line. |
I think |
hm, does not look like it.
|
What backend are you using |
The issue is that the horizontal bar is just a _ marker and not all backends support it |
|
I found a solution that works in my case but does (so far) not cover all cases. The problem is that the currently the caps are drawn using a My code modifies the
|
How would you decide on the width of these lines? |
Try commenting out Plots.jl/src/backends/pyplot.jl Line 128 in 709a8a9
|
If marker is unsupported by a backend, then it is provided by Plots using lower level recipes. In that case using |
One reason to have it as it is right now is that we can start allowing custom marker shapes for errorbar plots fairly easy. But I could not figure out a way to invert those markers easily for bottom/top errorbar. Caps being markers (instead of linse) can give good customizability I think |
thank you, for your suggestions. |
128 line in pyplot.jl |
Please let me know your feedback with this |
Thank you for your help.
Here's my result: |
What about using |
I think pyplot got better at marker centering at the latest version |
so - is there a way to remove error bar caps without removing the error bars in GR? |
With #4362 that would be using Plots
plot(1:5, yerror=fill(0.2,5), markershape = :none) |
I cannot remove error bar caps with using Plots
plot(1:5, yerror=fill(0.2,5), markershape = :none) gives me this On the other hand, running function errorcap_coords(errorbar, errordata, otherdata; capsize)
ed = Vector{Plots.float_extended_type(errordata)}(undef, 0)
od = Vector{Plots.float_extended_type(otherdata)}(undef, 0)#[Vector{float_extended_type(odi)}(undef, 0) for odi in otherdata]
for (j, (edi, odj)) in enumerate(zip(errordata, otherdata))
#for (i, edi) in enumerate(errordata)
#odi = _cycle(odj, i)
e1, e2 = Plots.error_tuple(Plots._cycle(errorbar, j))
Plots.nanappend!(ed, [edi - e1, edi - e1])
Plots.nanappend!(ed, [edi + e2, edi + e2])
Plots.nanappend!(od, [odj-capsize/2, odj+capsize/2])
Plots.nanappend!(od, [odj-capsize/2, odj+capsize/2])
#end
end
return (ed, od)
end
@recipe function f(::Type{Val{:yerror}}, x, y, z)
Plots.error_style!(plotattributes)
#markershape := :hline
yerr = Plots.error_zipit(plotattributes[:yerror])
if z === nothing
plotattributes[:y], plotattributes[:x] = Plots.error_coords(yerr, y, x)
errcapy, errcapx = errorcap_coords(yerr, y, x; capsize=get(plotattributes, :capsize, 0.1))
Plots.nanappend!(plotattributes[:y], errcapy)
Plots.nanappend!(plotattributes[:x], errcapx)
else
plotattributes[:y], plotattributes[:x], plotattributes[:z] =
Plots.error_coords(yerr, y, x, z)
end
()
end
plot(1:5, yerror=fill(0.2,5), capsize = 0) gives me this |
i implemented the function mentioned here, but when i try to use for example "capsize = 5", i get following error ! Package pgfkeys Error: I do not know the key '/tikz/capsize', to which you pa (even with the example used in this thread: plot(1:5, yerror=fill(0.2,5), capsize = 0)) Could it have anything to do with me using PGFPlotsX? or did i do something wrong |
Is it possible to change size or completely remove the errorbar caps? Currently the defaults are ok, but they do not work great for all plots.
The text was updated successfully, but these errors were encountered: