How to plot bar chart starting from non-zero y-axis?


I am trying to plot a bar chart as below:

using StatsPlots
bar([4,5,6],fillcolor=[:red,:green,:blue],fillalpha=[0.2,0.4,0.6], group=["a","b","c"])

But this plot is starting from Y-axis zero. However, I am looking to plot Y-axis 3. Moreover, instead of x-axis values, I want the labels to correspond to each bar.

How can I plot based on my requirements?

Thanks in Advance!

You want ylim = (3, 6) and xticks = (1:3, string.('a':'c'))

(NB I’m currently seeing a weird error where if I use xticks as above as a kwarg in the bar call it doesn’t plot the first two ticks, but if I do xticks!(1:3, string.('a':'c')) after the bar call it works, and if I include an extra label which isn’t shown - xticks = (1:4, string.('a':'d')) - in the bar call it also works - if you can reproduce this I’ll open an issue)

1 Like

@nilshg: Thanks for your reply. It is working with the following code:
bar([4,5,6],fillcolor=[:red,:green,:blue],fillalpha=[0.2,0.4,0.6], ylim = (3, 6), xticks=(1:3, ("a","b","c")))

1 Like