I'm pretty much a beginner working with Python so I apologize if I use the wrong terminology. I have a question regarding stem plots using matplotlib. I want to plot the frequency of change on certain positions on a object. I have this pandas dataframe:
df = pd.DataFrame([
('315', '1',),
('497', '1',),
('615', '1',),
('646', '1',),
('729', '1',),
('803', '1',),
('882', '3',)
], columns=['position', 'freq'])
df
position freq
0 315 1
1 497 1
2 615 1
3 646 1
4 729 1
5 803 1
6 882 3
Now I want to make a stem plot like this:
plt.stem(df.position,df.freq)
However the positions in the dataframe is actually part of a larger range of values from 0-912 (the total length of the object). I want the stem plot to include these values on the x-axis to create a plot looking something like this:
Disregarding the color marked boxes on the axis and the way the plot is displayed, I only want to include the full range of x-values (0-912 and displaying the positions in the dataframe).