My code I currently have is below, I want to put a filled in red circle where I have the plt.text below. How would I do that?
plt.plot('Month', 'Total Profit', data=fruit_sales_df, color='g', ls='--')
plt.ylim(35000, 74999)
plt.text(11, 70476, '70476')
plt.title("Total Profit Trend by Month")
plt.xlabel("Month")
plt.ylabel("Total Profit")
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
plt.show()
CodePudding user response:
Meaning just a point? You can add data consisting of one point only.
import matplotlib.pyplot as plt
plt.plot([1, 2], [3, 4], color='g', ls='--')
plt.text(1.5, 3.7, '70476')
plt.plot(1.5, 3.5, color='red', marker='o')
plt.title("Total Profit Trend by Month")
plt.xlabel("Month")
plt.ylabel("Total Profit")
plt.show()
CodePudding user response:
You can call plt.plot(x, y, 'style') again to create a point, like:
import matplotlib.pyplot as plt
plt.plot([1,2,3,4], [1,2,3,4])
plt.plot(5, 5, 'ro') # Additional point in red
plt.plot(6, 6, 'go') # Additional point in green
plt.text(5, 5, "Text")
plt.axis([0, 8, 0, 8])
plt.title("Total Profit Trend by Month")
plt.xlabel("Month")
plt.ylabel("Total Profit")
plt.show()