Questions tagged [scatter-plot]

A scatter plot is a type of data visualization that reveals possible correlations between two variables. Data points are plotted on a two-dimensional plane using Cartesian coordinates. Use this tag if you have a programming question related to scatter plots, such as problems with computing or displaying the data. You should also tag which language or software libraries you are using.

A scatter plot is a type of mathematical diagram that reveals possible correlations between two variables. Data points are plotted on a two-dimensional plane using Cartesian coordinates. Series of points may be colorized to display additional data.

Link:

3562 questions
623
votes
7 answers

pyplot scatter plot marker size

In the pyplot document for scatter plot: matplotlib.pyplot.scatter(x, y, s=20, c='b', marker='o', cmap=None, norm=None, vmin=None, vmax=None, alpha=None, linewidths=None, faceted=True,…
LWZ
  • 11,670
  • 22
  • 61
  • 79
425
votes
9 answers

Scatter plot with different text at each data point

I am trying to make a scatter plot and annotate data points with different numbers from a list. So, for example, I want to plot y vs x and annotate with corresponding numbers from n. y = [2.56422, 3.77284, 3.52623, 3.51468, 3.02199] z = [0.15, 0.3,…
Labibah
  • 5,371
  • 6
  • 25
  • 23
253
votes
6 answers

How to do a scatter plot with empty circles in Python?

In Python, with Matplotlib, how can a scatter plot with empty circles be plotted? The goal is to draw empty circles around some of the colored disks already plotted by scatter(), so as to highlight them, ideally without having to redraw the colored…
Eric O. Lebigot
  • 91,433
  • 48
  • 218
  • 260
228
votes
8 answers

Setting different color for each series in scatter plot

Suppose I have three data sets: X = [1,2,3,4] Y1 = [4,8,12,16] Y2 = [1,4,9,16] I can scatter plot this: from matplotlib import pyplot as plt plt.scatter(X,Y1,color='red') plt.scatter(X,Y2,color='blue') plt.show() How can I do this with 10 sets? I…
Yotam
  • 10,295
  • 30
  • 88
  • 128
197
votes
4 answers

How to color scatter markers as a function of a third variable

I want to make a scatterplot (using matplotlib) where the points are shaded according to a third variable. I've got very close with this: plt.scatter(w, M, c=p, marker='s') where w and M are the data points and p is the variable I want to shade…
Thomas Collett
  • 1,981
  • 2
  • 13
  • 6
163
votes
14 answers

Scatterplot with marginal histograms in ggplot2

Is there a way of creating scatterplots with marginal histograms just like in the sample below in ggplot2? In Matlab it is the scatterhist() function and there exist equivalents for R as well. However, I haven't seen it for ggplot2. I started an…
Seb
  • 5,417
  • 7
  • 31
  • 50
146
votes
8 answers

Scatterplot with too many points

I am trying to plot two variables where N=700K. The problem is that there is too much overlap, so that the plot becomes mostly a solid block of black. Is there any way of having a grayscale "cloud" where the darkness of the plot is a function of the…
user702432
  • 11,898
  • 21
  • 55
  • 70
144
votes
8 answers

plot different color for different categorical levels

I have this data frame diamonds which is composed of variables like (carat, price, color), and I want to draw a scatter plot of price to carat for each color, which means different color has different color in the plot. This is easy in R with…
avocado
  • 2,615
  • 3
  • 24
  • 43
139
votes
3 answers

Control the size of points in an R scatterplot?

In R, the plot() function takes a pch argument that controls the appearance of the points in the plot. I'm making scatterplots with tens of thousands of points and prefer a small, but not too small dot. Basically, I find pch='.' to be too small,…
Nick
  • 21,555
  • 18
  • 47
  • 50
133
votes
4 answers

How to make a 3D scatter plot

I am currently have a nx3 matrix array. I want plot the three columns as three axis's. How can I do that? I have googled and people suggested using Matlab, but I am really having a hard time with understanding it. I also need it be a scatter plot.
user211037
  • 1,725
  • 5
  • 16
  • 11
114
votes
8 answers

How to create a scatter plot by category

I am trying to make a simple scatter plot in pyplot using a Pandas DataFrame object, but want an efficient way of plotting two variables but have the symbols dictated by a third column (key). I have tried various ways using df.groupby, but not…
user2989613
  • 1,231
  • 2
  • 9
  • 11
110
votes
3 answers

seaborn scatterplot marker size for ALL markers

I can't find out anywhere how to change the marker size on seaborn scatterplots. There is a size option listed in the documentation but it is only for when you want variable size across points. I want the same size for all points but larger than the…
DataMan
  • 3,115
  • 6
  • 21
  • 36
110
votes
4 answers

Multiple datasets on the same scatter plot

I want to plot multiple data sets on the same scatter plot: cases = scatter(x[:4], y[:4], s=10, c='b', marker="s") controls = scatter(x[4:], y[4:], s=10, c='r', marker="o") show() The above only shows the most recent scatter() I've also tried: plt…
Austin Richardson
  • 8,078
  • 13
  • 43
  • 49
102
votes
5 answers

How to animate a scatter plot

I'm trying to do an animation of a scatter plot where colors and size of the points changes at different stage of the animation. For data I have two numpy ndarray with an x value and y value: data.shape = (ntime, npoint) x.shape = (npoint) y.shape =…
Nicola Vianello
  • 1,916
  • 6
  • 21
  • 26
97
votes
3 answers

Color according to class labels

I have two vectors, one with values and one with class labels like 1,2,3 etc. I would like to plot all the points that belong to class 1 in red, to class 2 in blue, to class 3 in green etc. How can I do that?
user1050325
  • 1,252
  • 2
  • 10
  • 14
1
2 3
99 100