scatter-plot

Matlab: How to set color of legend in a scatter plot where each data point gets a different color?

别等时光非礼了梦想. 提交于 2020-01-04 05:42:10
问题 Here is the sample code: x = rand(100,1); y = rand(100,1); score = rand(100,1); figure; colormap(flipud(bone)); caxis([0 1]) axis([0 1 0 1]) scatter(x,y,50,score,'+','LineWidth',2); legend('scores'); I'm using the reversed 'bone' colormap which assigns pure white to score value 0 and pure black to score value 1. However, the legend seems to be automatically assigned the score 0, and so if you run the code the legend color is pure white and not visible. Is there any ways to fix that? Thanks.

5-D Kernel density estimation in R using “kde” function

做~自己de王妃 提交于 2020-01-03 17:45:49
问题 I want to perform Kernel density estimate for a 5-dimensional data (x,y,z,time,size) by using "kde" function in "ks" library of R. In it's manual it says it can do Kernel density estimate for 1- to 6-dimensional data (Page 24 of manual: http://cran.r-project.org/web/packages/ks/ks.pdf). My problem is that it says for more than 3 dimensions I need to specify eval.points. I don't know how can I specify the evaluation points because there is no example for more than 3 dimensions. For example if

5-D Kernel density estimation in R using “kde” function

穿精又带淫゛_ 提交于 2020-01-03 17:45:10
问题 I want to perform Kernel density estimate for a 5-dimensional data (x,y,z,time,size) by using "kde" function in "ks" library of R. In it's manual it says it can do Kernel density estimate for 1- to 6-dimensional data (Page 24 of manual: http://cran.r-project.org/web/packages/ks/ks.pdf). My problem is that it says for more than 3 dimensions I need to specify eval.points. I don't know how can I specify the evaluation points because there is no example for more than 3 dimensions. For example if

2-y Axes Plot with calculated absolute & relative Change in R

大兔子大兔子 提交于 2020-01-03 04:50:11
问题 I am trying to calculate two things in R, Relative & Absolute Change , & plot 2-y axis scatter plots . I am still seeking inputs on creating a 2-y axis plot for this type of data. set.seed(123) df=expand.grid(PatientID=1:3,time=1:3, Group=1:2) dat <- data.table(df,Outcome=as.integer(runif(9)*100)) Data Format df #sample PatientID time Outcome Group 1 1 87 1 1 2 32 1 1 3 76 2 2 1 21 2 2 2 23 3 2 3 23 3 ## Cont until 200 PatientID or volunteers and there are many outcome measure columns (33:290

Color code a scatter plot by group with a gradient

爷,独闯天下 提交于 2020-01-02 07:11:16
问题 I have XY data which I'd like to graph using a scatter plot , with R 's plotly package. set.seed(1) df <- data.frame(x=c(rnorm(30,1,1),rnorm(30,5,1),rnorm(30,9,1)), y=c(rnorm(30,1,1),rnorm(30,5,1),rnorm(30,9,1)), group=c(rep("A",30),rep("B",30),rep("C",30)),score=runif(90,0,1)) Each point is assigned to one of three groups ( df$group ) and has a score in the [0,1] range. I'm looking for a way to graph the data such that each group is colored with a different color but the shade of that color

Plotting circles with no fill, colour & size depending on variables using scatter

自作多情 提交于 2020-01-02 03:44:27
问题 The information I have to show on a plot are 2 coordinates: size & colour (no fill). The colour is important as I need a colormap type of graph to display the information depending on a colour value. I went about trying two different ways of doing this: Create specific circles and add the individual circles. circle1 = plt.Circle(x, y, size, color='black', fill=False) ax.add_artist(circle1) The problem with this method was that I could not find a way to set the colour depending on a colour

How do I define color groups based on numerical threshold values for ggplot2 scatterplot

夙愿已清 提交于 2020-01-01 11:39:00
问题 I have a data set that contains 2 variables x = event number & y = assay amplitude. I am trying to create a scatterplot in ggplot2 where all of the points that are > 3000 are colored in one color and all of the points < 3000 are in a different color. I can get the plot and change the color for all data points, but can't figure out how to define a color scheme based on the value threshold. Here is a sample of the data I'm using: dat <- data.frame(x=c(399, 16022, 14756, 2609, 1131, 12135, 7097,

Adding text labels to ggplot2 scatterplot

五迷三道 提交于 2019-12-31 12:12:18
问题 Is there a good way easy way to add text labels to the circles on the graph? I haven't able to do it using the directlabels package because I get the error: Error in direct.label.ggplot(p, "first.qp") : Need colour aesthetic to infer default direct labels." Here is the graph: And here is the code that I've been using: library(ggplot2) library(directlabels) #my data set: oc <- read.csv("http://www.columbia.edu/~mad2200/oc.csv") oc$percent_women <- oc$W_employment/(oc$M_employment+oc$W

Adding text labels to ggplot2 scatterplot

泪湿孤枕 提交于 2019-12-31 12:12:09
问题 Is there a good way easy way to add text labels to the circles on the graph? I haven't able to do it using the directlabels package because I get the error: Error in direct.label.ggplot(p, "first.qp") : Need colour aesthetic to infer default direct labels." Here is the graph: And here is the code that I've been using: library(ggplot2) library(directlabels) #my data set: oc <- read.csv("http://www.columbia.edu/~mad2200/oc.csv") oc$percent_women <- oc$W_employment/(oc$M_employment+oc$W

structure diagram where each members of group are connected to center and all cluster grand center in r

泄露秘密 提交于 2019-12-31 09:05:54
问题 I am trying to create a structure diagram from the data like the following: mydf <- data.frame ( group = rep (1:5, each = 20), z = rnorm (20, 10, 1), x = c(rnorm (20, 2, 0.5), rnorm (20, 2, 0.5), rnorm (20, 9, 0.5), rnorm (20, 9, 0.5),rnorm (20, 5, 0.5)), y = c(rnorm (20, 2, 0.5), rnorm (20, 9, 0.5), rnorm (20, 2, 0.5), rnorm (20, 9, 0.5), rnorm (20, 2, 0.5))) means <- aggregate(. ~ group, data = mydf, mean) gmx <-mean (mydf$x) gmy <- mean (mydf$y) library(ggplot2) ggplot(mydf, aes(x, y)) +