I have the following code to plot a line and a point:
df = pd.DataFrame({'x': [1, 2, 3], 'y': [3, 4, 6]}) point = pd.DataFrame({'x': [2], 'y': [5]}) ax = df.plot(x='x', y='y', label='line') ax = point.plot(x='x', y='y', ax=ax, style='r-', label='point')
How do I get the single data point to show up?
In single-point annotation we can use matplotlib. pyplot. text and mention the x coordinate of the scatter point and y coordinate + some factor so that text can be distinctly visible from the plot, and then we have to mention the text.
When plotting a single data point, you cannot plot using lines. This is obvious when you think about it, because when plotting lines you actually plot between data points, and so if you only have one data point then you have nothing to connect your line to.
1 Initialize a list for x and y, with a single value. 2 Limit x and y axis range for 0 to 5. 3 Lay out a grid in current line style. 4 Plot given x and y using plot () method, with marker="o", markeredgecolor="red", markerfacecolor="green". 5 To display the figure, use show () method.
Add a Single Data Point to a Line Chart Excel 1 Beside the source data, type the specified data point you will add in the chart. 2 Right-click the line chart, and click Select Data from the context menu. 3 In the Select Data Source dialog box, please click the Add button in the Legend Entries (Series) section. See More....
To plot a single point you can do something like this: plt.plot ([x], [y], marker='o', markersize=3, color="red")
To plot a single point you can do something like this:
plt.plot([x], [y], marker='o', markersize=3, color="red")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With