Striped Colors for e.g. bar plots in Julia

This is an image of a figure a friend made (in matlab), would it be possible to create a similar effect in Julia where the colour is striped (instead of monocolour)?
image
(in this case the stipes helps show that the 4th bar is a combination of the 2nd and 3rd)

One option using PyPlot:

using PyPlot
plt.rc("hatch", lw=4.0)
plt.bar(1:3, 1:3, color=["grey","green","orange"], edgecolor="black")
plt.bar([4], [4], color="orange", edgecolor="green", hatch=["//"])
plt.bar([4], [4], color="none", edgecolor="black")

PyPlot_hatched_barplot

2 Likes

In Makie:

using Makie, GLMakie
p = Makie.LinePattern(width=10, tilesize=(30,30), linecolor=:orange, background_color=:green);
barplot(1:3,strokewidth=2, color=["grey","green","orange"])
barplot!([4], [4], color=p, strokewidth=2)

6 Likes

This is great, thank’s both of you!
(is there a way to mark two answers as solutions?)

1 Like

Please mark Makie as solution.

this seems to simply give me an output

Combined{Makie.barplot, Tuple{Vector{Point{2, Float32}}}}

in Jupyter (as in that text instead of an image). Meanwhile scratching the last line (barplot!([4], [4], color=p, strokewidth=2)) I get a proper display (however without the last bar). Am I missing something obvious here?

Am I missing something obvious here?

Yes :wink:

This should become clear when using the more explicit, non magic version:

figure, axis, plotobject1 = barplot(1:3,strokewidth=2, color=["grey","green","orange"])
plotobject2  = barplot!(axis, [4], [4], color=p, strokewidth=2)
figure

The return value of plot!(...) is a plot object, which doesn’t display by default…

2 Likes

So pretty it is

Thanks a lot. Makie seems to be the cool stuff these days, maybe this is the signal I should finally go learn it properly…

4 Likes