Plotting a cumulative frequency line on a histogram with second y axis

Dear all:

I am struggling with plotting a histogram with a cumulative frequency line overlaid.
I want to use twinx() to display the second y axis, but my code does not work.

using Plots

# some doing for data
scores = floor.(Int64, rand(10)*100)

freq = fit(Histogram, english_scores, 0:10:100)
rel_freq = freq.weights ./ sum(freq.weights)
cum_reql_freq = cumsum(rel_freq)

# plot
histogram(scores, bins = 0:10:100)
subplt = twinx()
plot!(subplt,5:10:95 , cum_reql_freq)

This only gives (both in GR and PyPlot backends):
test

Looks like a bug in Plots to me, a simpler MWE is

using Plots

histogram(rand(50))

plot!(twinx(), rand(50))
2 Likes

Iā€™m also hit by this issue and can only get blank plots just like the original poster when I use twinx().
Is there any workaround for this? Downgrade Plots.jl?

until this is fixed. Use Plots 1.16.5

1 Like

This was fixed in Plots 1.17.0

2 Likes