# Striped Colors for e.g. bar plots in Julia

**URL:** <https://discourse.julialang.org/t/striped-colors-for-e-g-bar-plots-in-julia/64435>\
**Category:** Visualization\
**Tags:** plotting, plots\
**Created:** [July 10, 2021, 6:15pm UTC](https://discourse.julialang.org/t/striped-colors-for-e-g-bar-plots-in-julia/64435 "2021-07-10T18:15:59Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Torkel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/torkel/32/5030_2.png) [@Torkel](https://discourse.julialang.org/u/Torkel)\
**Post date:** [July 10, 2021, 6:15pm UTC](https://discourse.julialang.org/t/striped-colors-for-e-g-bar-plots-in-julia/64435/1 "2021-07-10T18:15:59Z")

</div>

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](https://global.discourse-cdn.com/julialang/original/3X/2/1/214929ed106dd9bbf1d9512a29192d9774a9cb19.png)  
(in this case the stipes helps show that the 4th bar is a combination of the 2nd and 3rd)

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [July 11, 2021, 10:42am UTC](https://discourse.julialang.org/t/striped-colors-for-e-g-bar-plots-in-julia/64435/2 "2021-07-11T10:42:00Z")

</div>

One option using PyPlot:

```julia
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](https://global.discourse-cdn.com/julialang/original/3X/5/c/5c47e4d189b6b15c6df69ac362c34b7893bc442c.png)

---

<div class="post-metadata">

**Author:** ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)\
**Post date:** [July 11, 2021, 2:37pm UTC](https://discourse.julialang.org/t/striped-colors-for-e-g-bar-plots-in-julia/64435/3 "2021-07-11T14:37:15Z")

</div>

In Makie:

```julia
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)

```

 ![image](https://global.discourse-cdn.com/julialang/original/3X/c/1/c1e02a8ea9ea516068dcc566e120a614dea4bdd5.png)

---

<div class="post-metadata">

**Author:** ![Torkel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/torkel/32/5030_2.png) [@Torkel](https://discourse.julialang.org/u/Torkel)\
**Post date:** [July 11, 2021, 4:03pm UTC](https://discourse.julialang.org/t/striped-colors-for-e-g-bar-plots-in-julia/64435/4 "2021-07-11T16:03:15Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [July 11, 2021, 4:04pm UTC](https://discourse.julialang.org/t/striped-colors-for-e-g-bar-plots-in-julia/64435/5 "2021-07-11T16:04:39Z")

</div>

Please mark Makie as solution.

---

<div class="post-metadata">

**Author:** ![Torkel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/torkel/32/5030_2.png) [@Torkel](https://discourse.julialang.org/u/Torkel)\
**Post date:** [July 11, 2021, 4:35pm UTC](https://discourse.julialang.org/t/striped-colors-for-e-g-bar-plots-in-julia/64435/6 "2021-07-11T16:35:24Z")

</div>

> [@sdanisch](#):
>
> ```julia
> 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)
> 
> ```

this seems to simply give me an output

```julia
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?

---

<div class="post-metadata">

**Author:** ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)\
**Post date:** [July 11, 2021, 4:42pm UTC](https://discourse.julialang.org/t/striped-colors-for-e-g-bar-plots-in-julia/64435/7 "2021-07-11T16:42:28Z")

</div>

> Am I missing something obvious here?

Yes 😉

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

```julia
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…

---

<div class="post-metadata">

**Author:** ![Torkel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/torkel/32/5030_2.png) [@Torkel](https://discourse.julialang.org/u/Torkel)\
**Post date:** [July 11, 2021, 4:44pm UTC](https://discourse.julialang.org/t/striped-colors-for-e-g-bar-plots-in-julia/64435/8 "2021-07-11T16:44:01Z")

</div>

So pretty it is

 ![image](https://global.discourse-cdn.com/julialang/original/3X/5/0/50244337c6b3a2c7802f742cc8406176dd5589b0.png)

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

---

<div class="post-metadata">

**Author:** ![AsgerHB](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/asgerhb/32/45064_2.png) [@AsgerHB](https://discourse.julialang.org/u/AsgerHB)\
**Post date:** [August 24, 2026, 9:27am UTC](https://discourse.julialang.org/t/striped-colors-for-e-g-bar-plots-in-julia/64435/9 "2026-08-24T09:27:01Z")

</div>

I’d like to offer the additional solution with Plots.jl:

```
bar(1:3, color=["grey","green","orange"], size=(300, 300), label=nothing)
bar!([4], [4], color=:green, label=nothing)
bar!([4], [4], color=:orange, fillstyle=:/, label=nothing)

```

 ![billede](https://global.discourse-cdn.com/julialang/original/3X/b/e/be40143d51612eef2c60f1f067b2e4173fee9e26.png)  
Though I don’t know how to make the lines any thicker
