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
95
votes
5 answers

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'm using is: colors=['b', 'c', 'y', 'm', 'r'] lo…
user2386081
  • 1,087
  • 3
  • 10
  • 9
82
votes
8 answers

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
  • 4,742
  • 11
  • 59
  • 83
80
votes
5 answers

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(): return np.random.uniform(low=0., high=1.,…
Gabriel
  • 40,504
  • 73
  • 230
  • 404
79
votes
2 answers

How to add trendline to a scatter plot

How could I add a trendline to a dot graph drawn using matplotlib.scatter?
user3476791
  • 1,072
  • 1
  • 9
  • 14
73
votes
6 answers

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 love to be able to do this with…
zach
  • 29,475
  • 16
  • 67
  • 88
65
votes
6 answers

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? By square shape I mean two requirements: The…
Ali
  • 9,440
  • 12
  • 62
  • 92
64
votes
5 answers

Is there a function to make scatterplot matrices in matplotlib?

Example of scatterplot matrix Is there such a function in matplotlib.pyplot?
hatmatrix
  • 42,883
  • 45
  • 137
  • 231
64
votes
1 answer

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
  • 1,561
  • 3
  • 15
  • 18
61
votes
2 answers

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. For example, I have this code to plot some…
pceccon
  • 9,379
  • 26
  • 82
  • 158
57
votes
4 answers

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; however when I do, I get a very thick border around the…
David E
  • 888
  • 2
  • 8
  • 13
56
votes
4 answers

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,…
Mika Ike
  • 717
  • 1
  • 6
  • 9
52
votes
2 answers

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 error message I do not understand: TypeError: ufunc…
Bogdan Janiszewski
  • 2,743
  • 3
  • 20
  • 25
52
votes
2 answers

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) and (point a + error on a). Is there a way of…
user3412782
  • 561
  • 1
  • 4
  • 9
49
votes
2 answers

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- and y-axis are exactly the same size no matter…
Keith W. Larson
  • 1,543
  • 2
  • 19
  • 34
43
votes
3 answers

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 there is an issue. The points overlap in many regions…
papafe
  • 2,959
  • 4
  • 41
  • 72