I would like to change the color of the line graph I drew in Pandas.DataFrame.Plot from the middle of the x-axis.
For example, if the x-axis is 3 or more below, how do I change the color of the line to red?
Please let me know if you can't find the same question.
import pandas as pd
a = {'x-axis': [1,2,3,4,5], 'y-axis': [1,2,3,4,5]}
df=pd.DataFrame(data=a)
df.plot(x='x-axis', y='y-axis')
What about this?(Reference)
import pandas as pd
import matplotlib.pyplot asplt
a = {'x-axis': [1,2,3,4,5], 'y-axis': [1,2,3,4,5]}
df=pd.DataFrame(data=a)
N = 3.0
ax=df['x-axis'].plot()
df.loc [df.index>=N, 'x-axis'].plot (color='r', ax=ax)
ax=df.plot(x='x-axis', y='y-axis')
plt.show()
© 2024 OneMinuteCode. All rights reserved.