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.

scatter-plot
Filter by
Sorted by
Tagged with
635 votes
7 answers
1.8m views

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, ...
LWZ's user avatar
  • 11.9k
444 votes
9 answers
751k views

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....
Labibah's user avatar
  • 5,581
265 votes
6 answers
464k views

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 ...
Eric O. Lebigot's user avatar
234 votes
8 answers
928k views

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='...
Yotam's user avatar
  • 10.5k
202 votes
4 answers
357k views

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 ...
Thomas Collett's user avatar
165 votes
14 answers
92k views

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,...
Seb's user avatar
  • 5,467
164 votes
5 answers
521k views

How to connect scatterplot points with line using matplotlib

I have two lists, dates and values. I want to plot them using matplotlib. The following creates a scatter plot of my data. import matplotlib.pyplot as plt plt.scatter(dates,values) plt.show() plt....
brno792's user avatar
  • 6,639
147 votes
8 answers
116k views

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" ...
user702432's user avatar
146 votes
8 answers
328k views

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 ...
avocado's user avatar
  • 2,685
143 votes
3 answers
399k views

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 ...
Nick's user avatar
  • 21.9k
135 votes
4 answers
303k views

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 ...
user211037's user avatar
  • 1,775
122 votes
5 answers
494k views

How to plot two columns of a pandas data frame using points

I have a pandas dataframe and would like to plot values from one column versus the values from another column. Fortunately, there is plot method associated with the dataframes that seems to do what I ...
Roman's user avatar
  • 128k
118 votes
3 answers
171k views

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 ...
DataMan's user avatar
  • 3,305
114 votes
8 answers
265k views

How to create a scatter plot by category [duplicate]

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 ...
user2989613's user avatar
  • 1,231
112 votes
3 answers
368k views

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 ...
Austin Richardson's user avatar
103 votes
5 answers
145k views

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....
Nicola Vianello's user avatar
98 votes
3 answers
197k views

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 ...
user1050325's user avatar
  • 1,262
96 votes
5 answers
368k views

Matplotlib scatter plot legend

I created a 4D scatter plot graph to represent different temperatures in a specific area. When I create the legend, the legend shows the correct symbol and color but adds a line through it. The code I'...
user2386081's user avatar
  • 1,097
86 votes
6 answers
107k views

Setting a fixed size for points in legend

I'm making some scatter plots and I want to set the size of the points in the legend to a fixed, equal value. Right now I have this: import matplotlib.pyplot as plt import numpy as np def rand_data(...
Gabriel's user avatar
  • 41.8k
83 votes
8 answers
235k views

How to overplot a line on a scatter plot in python?

I have two vectors of data and I've put them into pyplot.scatter(). Now I'd like to over plot a linear fit to these data. How would I do this? I've tried using scikitlearn and np.polyfit().
goldisfine's user avatar
  • 4,810
80 votes
2 answers
162k views

How to add trendline to a scatter plot

How could I add a trendline to a dot graph drawn using matplotlib.scatter?
user3476791's user avatar
  • 1,082
75 votes
6 answers
192k views

Color a scatter plot by Column Values

One of my favorite aspects of using the ggplot2 library in R is the ability to easily specify aesthetics. I can quickly make a scatterplot and apply color associated with a specific column and I would ...
zach's user avatar
  • 30.4k
68 votes
6 answers
73k views

Force ggplot2 scatter plot to be square shaped

I can force ggplot2 scatter plot to be square shaped with the same x and y scaling using xlim() and ylim(), but it needs manual calculation of the limits. Is there any more convenient way of doing it? ...
Ali's user avatar
  • 9,650
67 votes
1 answer
84k views

Matplotlib: Scatter Plot to Foreground on top of a Contour Plot

Does anyone know a way to bring a scatter plot to the foreground in matplotlib? I have to display the scatter plotting on top of the contour, but by default it is plotted underneath...
Mike's user avatar
  • 1,611
65 votes
5 answers
81k views

Is there a function to make scatterplot matrices in matplotlib?

Example of scatterplot matrix Is there such a function in matplotlib.pyplot?
hatmatrix's user avatar
  • 43.9k
62 votes
3 answers
163k views

Creating Pandas Dataframe between two Numpy arrays, then draw scatter plot

I'm relatively new with numpy and pandas (I'm an experimental physicist so I've been using ROOT for years...). A common plot in ROOT is a 2D scatter plot where, given a list of x- and y- values, makes ...
n3utrino's user avatar
  • 1,180
61 votes
2 answers
60k views

Individual alpha values in scatter plot

I'm wondering if it is possible to have individual alpha values for each point to be plotted using the scatter function of Matplotlib. I need to plot a set of points, each one with its alpha value. ...
pceccon's user avatar
  • 9,634
57 votes
4 answers
138k views

How to change marker border width and hatch width?

In this example of a marker from my scatter plot, I have set the color to green, and edge color to black, and hatch to "|". For the hatch pattern to show up at all, I must set the edgecolor;...
David E's user avatar
  • 888
56 votes
4 answers
206k views

How can I label points in this scatterplot?

Can you help me on putting labels on the following graph? The code i use is: valbanks<-scan("banks.txt", what=list(0,0,""), sep="", skip=1, comment.char="#") valbanks valj2007<-valbanks[[1]]...
Mika Ike's user avatar
  • 717
53 votes
2 answers
147k views

Scatter plot error bars (the error on each point is unique)

I am attempting a scatter plot of 2 arrays for which I have a third array containing the absolute error (error in y direction) on each point. I want the error bars to between (point a - error on a) ...
user3412782's user avatar
51 votes
2 answers
48k views

Matplotlib scatter plot with unknown error

I am attempting to create a scatter plot. I have a list of numbers from 0 - 17 as well as an array with 18 values. I can plot the data as a line plot but when I try to plot as a scatter, I get an ...
Bogdan Janiszewski's user avatar
49 votes
2 answers
54k views

How to define fixed aspect-ratio for (base R) scatter-plot

I am plotting correlation coefficients (values = 0.0:1.0) for two isotopes measured in each individual from two populations. I would like to have a fixed aspect-ratio for my scatter-plot so that the x-...
Keith W. Larson's user avatar
48 votes
4 answers
39k views

Partially transparent scatter plot, but with a solid color bar

In Python, with Matplotlib, how to simply do a scatter plot with transparency (alpha < 1), but with a color bar that represents their color value, but has alpha = 1? Here is what one gets, with ...
Eric O. Lebigot's user avatar
47 votes
4 answers
62k views

Visualization of scatter plots with overlapping points in matplotlib

I have to represent about 30,000 points in a scatter plot in matplotlib. These points belong to two different classes, so I want to depict them with different colors. I succeded in doing so, but ...
papafe's user avatar
  • 3,047
46 votes
2 answers
41k views

Changing the background color of the axes planes of a 3D plot

On the basis of the scatterplot example of matplotlib, how can I change the gray background color of the 3 axes grid planes? I would like to set it to white, keeping the grid lines with the default ...
user1520280's user avatar
41 votes
3 answers
101k views

Python scatter plot. Size and style of the marker

I have a set of data that I want to show as a scatter plot. I want each point to be plotted as a square of size dx. x = [0.5,0.1,0.3] y = [0.2,0.7,0.8] z = [10.,15.,12.] ...
Brian's user avatar
  • 14.5k
41 votes
5 answers
21k views

How to improve the label placement in scatter plot

I use matplotlib to plot a scatter chart: And label the bubble using a transparent box according to the tip at How to annotate point on a scatter automatically placed arrow Here is the code: if ...
bigbug's user avatar
  • 57.9k
41 votes
2 answers
65k views

3D Scatter Plot with Colorbar

Borrowing from the example on the Matplotlib documentation page and slightly modifying the code, import numpy as np from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt def ...
JC.'s user avatar
  • 639
40 votes
4 answers
93k views

Adding y=x to a matplotlib scatter plot if I haven't kept track of all the data points that went in

Here's some code that does scatter plot of a number of different series using matplotlib and then adds the line y=x: import numpy as np, matplotlib.pyplot as plt, matplotlib.cm as cm, pylab nseries =...
kuzzooroo's user avatar
  • 7,088
40 votes
3 answers
187k views

How to change the font size and color of x-axis and y-axis label in a scatterplot with plot function in R?

I used the following code to draw a scatterplot. How to increase the font size and change colour of x-axis and y-axis label? data=read.csv("data.csv") plot(data$column1,data$column2,xlab="x axis", ...
rebca's user avatar
  • 1,179
40 votes
5 answers
138k views

Plotting multiple scatter plots pandas

I think there are many questions on plotting multiple graphs but not specifically for this case as shown below. The pandas documentation says to 'repeat plot method' to plot multiple column groups in ...
Amoroso's user avatar
  • 973
39 votes
3 answers
168k views

Superimpose scatter plots

I am using Python matplotlib. i want to superimpose scatter plots. I know how to superimpose continuous line plots with commands: >>> plt.plot(seriesX) >>> plt.plot(Xresampl) >&...
kiriloff's user avatar
  • 26k
39 votes
6 answers
91k views

How to make Matplotlib scatterplots transparent as a group?

I'm making some scatterplots using Matplotlib (python 3.4.0, matplotlib 1.4.3, running on Linux Mint 17). It's easy enough to set alpha transparency for each point individually; is there any way to ...
Jason's user avatar
  • 493
38 votes
2 answers
132k views

"Error: Continuous value supplied to discrete scale" in default data set example mtcars and ggplot2

I am trying to replicate the example here (sthda.com) using the following code: # Change point shapes and colors manually ggplot(mtcars, aes(x=wt, y=mpg, color=cyl, shape=cyl)) + geom_point() + ...
Katherine Hepworth's user avatar
36 votes
1 answer
19k views

How to jitter text to avoid overlap in a ggplot2 scatterplot?

I would like to create a clean version of a scatterplot of text labels in ggplot2. The goal is to represent visually the increasing values associated with about 25 items. I am already using "...
user1257313's user avatar
  • 1,067
36 votes
0 answers
1k views

Interactive selection in ggplotly with geom_hex() scatterplot

I am trying to create a scatterplot matrix with interactive selection between geom items in individual matrix plots. This works when I am dealing with geom_points (inside ggpairs()). When a user ...
user avatar
35 votes
3 answers
98k views

Specify color of each point in 3d scatter plot

I have a 3D Plot that I created using matplotlib, and I have a list of rbg values that correspond to each point. I have the X, Y, and Z data, and then I have a "color list" of the form: [ (r,g,b), (...
codycrossley's user avatar
34 votes
3 answers
31k views

How to annotate point on a scatter automatically placed arrow

if I make a scatter plot with matplotlib: plt.scatter(randn(100),randn(100)) # set x, y lims plt.xlim([...]) plt.ylim([...]) I'd like to annotate a given point (x, y) with an arrow pointing to it ...
user avatar

1
2 3 4 5
92