Hey this is the plot which I want to create
And here are the details: on x
axis I want to have the numbers from 0
to 10
, on y
axis I want to have values from 0
do 60
. For each i
from interval [0, 10]
, I have 10000
numbers. Black line is the mean of all the numbers for each i
. For selected i
s (i=2
and i=6
on the graph) I want to plot histogram vertically. What is important I want to use density=True
in hist
function. The most difficult part is to fix the height of all the histograms to 3
in terms of x
axis values (red one starts at 2 and the highest point is at 5 and the blue one starts at 6 and ends at 9 so the height is 3). Is anyone able to help me? Below is my current code and the plot which is produced - unfortunately the height is much too small.
import numpy as np
import matplotlib.pyplot as plt
x = range(11)
res = np.random.randint(0, 60, size = (11, 10000))
means = [res[i, :].mean() for i in x]
fig, ax = plt.subplots(figsize = (12, 6), dpi = 300)
ax.plot(x, means)
ax.hist(res[2,:], bins = 100, density = True, orientation = 'horizontal', bottom = 2)
CodePudding user response: