scatter-plot

How can a data ellipse be superimposed on a ggplot2 scatterplot?

老子叫甜甜 提交于 2019-11-26 15:36:07
问题 I have an R function which produces 95% confidence ellipses for scatterplots. The output looks like this, having a default of 50 points for each ellipse (50 rows): [,1] [,2] [1,] 0.097733810 0.044957994 [2,] 0.084433494 0.050337990 [3,] 0.069746783 0.054891438 I would like to superimpose a number of such ellipses for each level of a factor called 'site' on a ggplot2 scatterplot, produced from this command: > plat1 <- ggplot(mapping=aes(shape=site, size=geom), shape=factor(site)); plat1 + geom

Scatterplot with too many points

拟墨画扇 提交于 2019-11-26 15:35:58
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 number of points in an region? In other words, instead of showing individual points, I want the plot to be a "cloud", with the more the number of points in a region, the darker that region. One way to deal with this is with alpha blending, which makes each point slightly transparent. So regions appear darker that have more point plotted on them.

Setting different color for each series in scatter plot on matplotlib

主宰稳场 提交于 2019-11-26 14:04:16
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 searched for this and could find any reference to what I'm asking. Edit: clarifying (hopefully) my question If I call scatter multiple times, I can only set the same color on each scatter. Also, I know I can set a color array manually but I'm sure there is a better way to do this. My question is then, "How can I automatically scatter-plot my several

How to make a 3D scatter plot in Python?

心已入冬 提交于 2019-11-26 12:53:57
问题 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. Can someone teach me? 回答1: You can use matplotlib for this. matplotlib has a mplot3d module that will do exactly what you want. from matplotlib import pyplot from mpl_toolkits.mplot3d import Axes3D import random fig = pyplot.figure() ax = Axes3D

Is there a function to make scatterplot matrices in matplotlib?

二次信任 提交于 2019-11-26 10:19:07
问题 Example of scatterplot matrix Is there such a function in matplotlib.pyplot? 回答1: Generally speaking, matplotlib doesn't usually contain plotting functions that operate on more than one axes object (subplot, in this case). The expectation is that you'd write a simple function to string things together however you'd like. I'm not quite sure what your data looks like, but it's quite simple to just build a function to do this from scratch. If you're always going to be working with structured or

Scatterplot with marginal histograms in ggplot2

巧了我就是萌 提交于 2019-11-26 05:38:43
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 attempt by creating the single graphs but don't know how to arrange them properly. require(ggplot2) x<-rnorm(300) y<-rt(300,df=2) xy<-data.frame(x,y) xhist <- qplot(x, geom="histogram") + scale_x_continuous(limits=c(min(x),max(x))) + opts(axis.text.x = theme_blank(), axis.title.x=theme_blank(), axis.ticks = theme_blank(), aspect.ratio = 5/16, axis

Scatterplot with too many points

眉间皱痕 提交于 2019-11-26 04:29:20
问题 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 number of points in an region? In other words, instead of showing individual points, I want the plot to be a \"cloud\", with the more the number of points in a region, the darker that region. 回答1: One way to deal with this is with alpha blending

Scatterplot with marginal histograms in ggplot2

可紊 提交于 2019-11-26 03:25:50
问题 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 attempt by creating the single graphs but don\'t know how to arrange them properly. require(ggplot2) x<-rnorm(300) y<-rt(300,df=2) xy<-data.frame(x,y) xhist <- qplot(x, geom=\"histogram\") + scale_x_continuous(limits=c(min(x),max(x))) + opts(axis

Setting different color for each series in scatter plot on matplotlib

人走茶凉 提交于 2019-11-26 01:56:25
问题 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 searched for this and could find any reference to what I\'m asking. Edit: clarifying (hopefully) my question If I call scatter multiple times, I can only set the same color on each scatter. Also, I know I can set a color array manually but I\'m

python matplotlib update scatter plot from a function

有些话、适合烂在心里 提交于 2019-11-26 01:54:16
问题 I am trying to automatically update a scatter plot. The source of my X and Y values is external, and the data is pushed automatically into my code in a non-predicted time intervals (rounds). I have only managed to plot all the data when the whole process ended, whereas I am trying to constantly add and plot data into my canvas. What I DO get (at the end of the whole run) is this: Whereas, what I am after is this: A simplified version of my code: import matplotlib.pyplot as plt def read_data()