scatter

How to specify different color for a specific year value range in a single figure? (Python)

徘徊边缘 提交于 2019-11-29 09:00:28
I've a time-series dataset, from 1992-2017. I can set a color for the whole data dots but what I want is to set desired color for specific year range. For Example; from 1992-1995 "Blue", from 1995-2005 "Red" etc. How can we do that? Dataset has 2 columns; year and value. import numpy as np import pandas as pd from scipy import stats from sklearn import linear_model from matplotlib import pyplot as plt import pylab import matplotlib.patches as mpatches import matplotlib.pyplot as plt import seaborn as sns from sklearn.linear_model import LinearRegression Atlantic = pd.read_csv('C:\\AtlanticEnd

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

元气小坏坏 提交于 2019-11-29 06:15:20
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() + geom_smooth(method=lm, se=FALSE, fullrange=TRUE)+ scale_shape_manual(values=c(3, 16, 17))+ scale_color_manual(values=c('#999999','#E69F00', '#56B4E9'))+ theme(legend.position="top") The example on that web page says that code should produce the following result: But when I run it in R, I get the following error: "Error: Continuous value supplied to discrete scale" Does anyone know what could be wrong

R- plot numbers instead of points

谁说胖子不能爱 提交于 2019-11-29 03:08:31
I have successfully made a scatterplot, with different symbols for each data series. But what I want to do is make the same scatterplot with the point to show up as numbers. Not the value of each point, just an assigned number. As of right now, I have three depths I am plotting (0, 3, 6cm). I have all my 0cm as triangles, etc. I want my 0cm points to be the character 0, the 3cm points to show up as 3, and the 6cm points to show up as 6. Is this possible? Sure, just pass the pch parameter as a character. dat <- data.frame(x=rnorm(100), y1=rnorm(100)-1, y2=rnorm(100), y3=rnorm(100)+1) plot(y1 ~

Gnuplot: How to make scatter plots with transparent points

痞子三分冷 提交于 2019-11-29 01:37:19
How can I plot an image with partial transparent scatter points just like in this picture with gnuplot? The problem is I don't know how to set the points to be transparent. Try this: set style fill transparent solid 0.35 noborder set style circle radius 0.02 plot 'test' u 1:2 with circles lc rgb "blue", \ '' u 1:2 every 100 w circles lc rgb "red" fs solid 1.0 border lt -1 which outputs As you can see, you can specify for each data set whether to use transparency and which color to use. If your data consist of two values (x and y position of the circle) you have to specify the circle's radius

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

和自甴很熟 提交于 2019-11-29 01:06:49
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... Thanks in advance! You can manually choose in which order the different plots are to be displayed with the zorder parameter of e.g. the scatter method. To demonstrate, see the code below, where the scatter plot in the left subplot has zorder=1 and in the right subplot it has zorder=-1 . The object with the highest zorder is placed on top. This means that the scatter will be placed on top of the contour in the

Matplotlib 3D scatter plot with color gradient

橙三吉。 提交于 2019-11-28 23:24:23
How can I create a 3D plot with a color gradient for the points? See the example below, which works for a 2D scatter plot. Edit (thanks to Chris): What I'm expecting to see from the 3D plot is a color gradient of the points ranging from red to green as in the 2D scatter plot. What I see in the 3D scatter plot are only red points. Solution: for some reasons (related to the gradient example I copied elsewhere) I set xrange to len-1, which messes everything in the 3D plot. import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D # Create Map cm = plt.get_cmap(

Partially transparent scatter plot, but with a solid color bar

我是研究僧i 提交于 2019-11-28 19:11:18
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 from pylab import *; scatter(range(10), arange(0, 100, 10), c=range(10), alpha=0.2); color_bar = colorbar() : How can the color bar be made non-transparent? PS : I tried color_bar.set_alpha(1); draw() , but this did not do anything… Alright, I found one way to do it, that looks relatively clean: (using the ColorBar object from the question) color_bar.set_alpha(1) color_bar.draw_all() # pylab.draw() or

limit the axes for plotting in Matlab [duplicate]

三世轮回 提交于 2019-11-28 14:51:40
Possible Duplicate: is it possible to select a particular region in a scatterplot is it possible to reduce the datapoints from the input text file, so that those dont come in my calculation. I am using following to read the data fid = fopen('cr.txt'); A = textscan(fid, '%f %f %f %f %f %*f %*f %*f %*f %*f %*s %*s %*s') ; %read the file a = A{1}; e = A{2}; c = A{3}; x = A{4}; y = A{5}; here x,y are the distances and if I apply xlim and ylim, I want to limit the corresponding a,e,c from the file also. the file has around million data points. And I will be further plotting the x,y and z(which is

is it possible to select a particular region in a scatterplot

时间秒杀一切 提交于 2019-11-28 14:04:04
问题 I am basically plotting several million data points with help of scatterplot. here I am doing scatter(x(1:end-1), y(1:end-1),5, z) Now is possible to select a particular area in the plot...and find out the values. I dont know if you will understand my question or not. As an alternative is it possible to reduce the datapoints from the beginning itself, so that those dont come in my calculation. I am using following to read the data fid = fopen('cr.txt'); A = textscan(fid, '%f %f %f %f %f %*f %

scatter plot data does not appear on continents in 'hammer' basemap

帅比萌擦擦* 提交于 2019-11-28 13:46:30
I am attempting to plot a dataset over the 'hammer' basemap using a scatter plot. However, the data points won't plot on top of the continents. I noticed in the matplotlib example , there is also not data on the continents (I assumed this was due to the nature of the example). I'm wondering if I'm doing something wrong, or if data cannot be plotted on top of the continents using 'hammer' by design. If this is the case, is there an ideal basemap to use to plot scatter plot data over the whole Earth (using a relief map would be great, but I would settle for anything at this point)? You're