How to reduce bar padding in horizontal bar plotting?

How can I set the bar padding in bar ?

using Plots
kDiff = [-0.4665307712613753, 1.3988034802362372, 0.26964352271121106, 1.9321483556515853, 0.027055373158908935, -0.2508916681408131]
sentences = ["Industrie", "Noeffect", "Independant", "Biod", "Recognition", "NewMarkets"]
bar(sentences,kDiff,orientation = :horizontal, bar_width=0.02,legend=nothing)

image

I did try aspect_ratio, it reduces the padding at the center but it still does leave lot of space above and below the chart.

My “ideal” situation would be to regulate the relative space between the axis labels and the axis data, and inverting it to have the labels on the right, something like this (with short lines in place of the pluses):

++        I am attentive to the expectation of the industry [Industrie]
     +++  The actions I could do in my forests will not make any significant differences in terms of outcomes [Noeffect]
     +    I am an independent producer of wood (fuel and/or timber) and I look after my forest in the same way as my predecessors.[Independant]
     +++  My role is to promote biodiversity or other amenities, wood production is only a secondary objective.[Biod]
          I want people to know about the work I do in forest and/or my engagement [Recognition]
+         I am open to innovations and new markets [NewMarkets]

Interesting application. There are probably a few ways to do this with Plots.jl, but one approach is to (i) set the size keyword to the appropriate aspect ratio, and then (ii) use twinx() to plot dummy data on the right axis with the sentences. So something like:

using Plots, Plots.PlotMeasures
gr()
kDiff = [-0.4665307712613753, 1.3988034802362372, 0.26964352271121106, 1.9321483556515853, 0.027055373158908935, -0.2508916681408131];
sentences = ["I am attentive to the expectation of the industry", "The actions I could do in my forests will not make any significant differences in terms of outcomes", "I am an independent producer of wood (fuel and/or timber) and I look after my forest in the same way as my predecessors.", "My role is to promote biodiversity or other amenities, wood production is only a secondary objective.", "I want people to know about the work I do in forest and/or my engagement", "I am open to innovations and new markets"];
sentencesplot = bar(sentences,kDiff,orientation = :horizontal, bar_width=0.02,legend=nothing, size=(1000,150), yticks=nothing, right_margin=175mm);
rightaxis = twinx();
plot!(rightaxis, rand(6), color=:transparent, sentences, legend=nothing, size=(1000,150))
savefig(sentencesplot, "sentencesplot.png")

1 Like

Thank you very much, perfect.
In order to remove the axis on the left I can then use yaxis=false in the first call.