Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to plot one single data point?

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?

Plot with line and no point

like image 730
Peter Knutsen Avatar asked Jan 05 '15 12:01

Peter Knutsen


People also ask

How do you label a single point in a Matplotlib graph in Python?

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.

Why can’t I plot a single data point?

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.

How to plot one single data point in Matplotlib?

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.

How to add a single data point to a line chart?

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....

How do I plot a single point in a graph?

To plot a single point you can do something like this: plt.plot ([x], [y], marker='o', markersize=3, color="red")


1 Answers

To plot a single point you can do something like this:

plt.plot([x], [y], marker='o', markersize=3, color="red") 
like image 194
Andrei Pokrovsky Avatar answered Sep 24 '22 08:09

Andrei Pokrovsky