Plot xticks correctly

I’m trying to reproduce this bar plot:

With the following code:

using Plots,DelimitedFiles
f = readdlm("ch3_data_english.txt")
xticks = (1:26,'a':'z'),
yticks = 0:0.02:0.2,
ylims = (0,0.13),xlims = (1,26),
color = RGB(0.9,0.6,0),
label = false)

Which output is

My only complaint is that the little lines above the letters don’t show up, how do I fix that?

1 Like

That would be an interesting feature. I discovered that the ticks show up reducing the alpha argument, there is a way to plot the bars behind the ticks ?

Changing the backend to PyPlot and a:z to string.(a:z) the result is:

That’s almost perfect, now I only need the ticks to appear.

The Box you can get with GR with framestyle=:box.

In case you don’t want to change the default backend (I noticed that this is one example of that book).

1 Like

What’s the use of those ticks? There is one bar per label, and they are in direct connection. The fact that Plots.jl removes them is good-actually.

I don’t think they r dropped, just they r being at the background. at q there is a small tick

Use the plots argument: tick_direction=:out, to get the ticks outside the box.


It is probably not needed to reproduce exactly the same plot layout in reproducing those examples of the book. I guess the python and matlab codes that are shown do not produce identical plots either (keeping the code simple is likely a preferable goal).

1 Like

Speaking of xticks, I am wondering if the docs of Plots.jl concerning the attributes are not wrong. Here, I can see xsticks instead of xticks. Is it a mistake?

That seems to be a line type (“sticks along x”) for gaston() and pgfplotsx() backends. Not the same thing as xticks attribute:

using Plots; pgfplotsx()
plot(rand(10), lt=:xsticks)

1 Like

That’s true, the pyhon code certainly do not reproduce a identical plot, I will choose a more simple approach.