Reputation: 802
I have a list of atom indices and corresponding RMSF values, one index per RMSF value, and I would like to plot these in matplotlib in a larger python environment (Jupyter notebooks). I am only plotting a subset index numbers, called selectacarbons
and have created their corresponding data points, called rmsfacarbons
. The selectacarbons
picks out 1876 selections from a much bigger group of 31,000 indices - in the big group of indices their index numbers go sequentially, i.e. 1, 2, 3, 4, ..., 31,000 whereas for selectacarbons
they are not sequential, i.e. 5, 13, 32, 63, ..., 31,000. My first attempt at plotting:
import matplotlib as plt
plt.plot(selectacarbons, rmsfacarbons)
plt.xlabel('index of the alpha carbons')
plt.ylabel('RMSF (Å)')
plt.title('alpha carbons RMSF')
gave me a plot with the correct data, but an x-axis ranging from 0-31,000 (the length of the initial, larger dataset). I would like the exact same data but the x-axis to range from 0-1876, so I tried adding these to the above code:
plt.axis([0, 1876, 0, 1.6])
length = (len(selectacarbons))
plt.xlim([0, length])
plt.xlim([min(selectacarbons), max(selectacarbons)])
Again, all of the 1876 selections in selectacarbons
came with an original, non-sequential index identifier such as 5, 13, 32, 63, ..., 31,000. All of these tries above simply plot the fraction of data in selectacarbons
that is in the range 0-1876 and does not plot all 1876 data points in selectacarbons
. How can I change the axis to represent the number of data points instead of the length of the data points?
Upvotes: 0
Views: 428
Reputation: 96
Maybe this is enough for you?
plt.plot(range(len(selectacarbons)), rmsfacarbons)
Or if you want to plot the exact same plot and change only the axis, you can play with
xticks(Where you want labels on the axis)
xticklabels(The labels you want at these places)
Upvotes: 2