scatter-plot

Using colormap with bokeh scatter

橙三吉。 提交于 2019-12-03 07:41:49
In matplotlib the scatterplot offers the possibility of using the color of a plot to indicate value or magnitude like this plot: For bokeh , similar examples seem to manually generate the rgb colors, which makes it difficult to produce plots with color scaled by magnitude, esp. wrt. diverging colormaps. Is it possible to have similar functionality in bokeh , or to use matplotlib colormaps to set the color? It's easy enough to just use matplotlib 's colormaps directly. For example, the following uses viridis in bokeh 's example (note that I'm using a jupyter notebook): import numpy as np from

How to reproduce smoothScatter's outlier plotting in ggplot?

萝らか妹 提交于 2019-12-03 07:28:08
问题 I am trying to get something like what the smoothScatter function does, only in ggplot. I have figured out everything except for plotting the N most sparse points. Can anyone help me with this? library(grDevices) library(ggplot2) # Make two new devices dev.new() dev1 <- dev.cur() dev.new() dev2 <- dev.cur() # Make some data that needs to be plotted on log scales mydata <- data.frame(x=exp(rnorm(10000)), y=exp(rnorm(10000))) # Plot the smoothScatter version dev.set(dev1) with(mydata,

Manipulating axis titles in ggpairs (GGally)

情到浓时终转凉″ 提交于 2019-12-03 04:22:19
问题 I'm using the code below to generate the following chart. # Setup data(airquality) # Device start png(filename = "example.png", units = "cm", width = 20, height = 14, res = 300) # Define chart pairs.chrt <- ggpairs(airquality, lower = list(continuous = "smooth"), diag = list(continuous = "blank"), upper = list(continuous = "blank")) + theme(legend.position = "none", panel.grid.major = element_blank(), axis.ticks = element_blank(), axis.title.x = element_text(angle = 180, vjust = 1, color =

R - Smoothing color and adding a legend to a scatterplot

好久不见. 提交于 2019-12-03 03:54:48
I have a scatterplot in R. Each (x,y) point is colored according to its z value. So you can think of each point as (x,y,z) , where (x,y) determines its position and z determines its color along a color gradient. I would like to add two things A legend on the right side showing the color gradient and what z values correspond to what colors I would like to smooth all the color using some type of interpolation, I assume. In other words, the entire plotting region (or at least most of it) should become colored so that it looks like a huge heatmap instead of a scatterplot. So, in the example below,

scatter plot in matplotlib

心不动则不痛 提交于 2019-12-02 23:47:46
This is my first matplotlib program, so sorry for my ignorance. I've two arrays of string. say, A = ['test1','test2'] and B = ['test3','test4'] . If any correlation exists between A and B element, their corr value will be set to 1 . test1 | test2 test3 | 1 | 0 test4 | 0 | 1 Now, I want to draw a scatter diagram where my X axis will be elements of A , Y axis will be elements of B and if correlation value is 1 , it'll be marked in the scattered plot. how to do that? Akavall Maybe something like this: import matplotlib.pyplot import pylab x = [1,2,3,4] y = [3,4,8,6] matplotlib.pyplot.scatter(x,y)

Visualization of scatter plots with overlapping points in matplotlib

一世执手 提交于 2019-12-02 22:26:55
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 and the class that I depict for last will be visualized on top of the other one, hiding it. Furthermore, with the scatter plot is not possible to show how many points lie in each region. I have also tried to make a 2d histogram with histogram2d and imshow, but it's difficult to show the points belonging to both classes in a clear way. Can you

Adding text labels to ggplot2 scatterplot

耗尽温柔 提交于 2019-12-02 22:24:07
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_employment) oc$size <- oc$W_employment+oc$M_employment p <- ggplot(oc, aes(M_w_earnings, W_w_earnings, label =

How to create a time scatterplot with R?

£可爱£侵袭症+ 提交于 2019-12-02 21:10:36
The data are a series of dates and times. date time 2010-01-01 09:04:43 2010-01-01 10:53:59 2010-01-01 10:57:18 2010-01-01 10:59:30 2010-01-01 11:00:44 … My goal was to represent a scatterplot with the date on the horizontal axis (x) and the time on the vertical axis (y). I guess I could also add a color intensity if there are more than one time for the same date. It was quite easy to create an histogram of dates. mydata <- read.table("mydata.txt", header=TRUE, sep=" ") mydatahist <- hist(as.Date(mydata$day), breaks = "weeks", freq=TRUE, plot=FALSE) barplot(mydatahist$counts, border=NA, col="

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

半腔热情 提交于 2019-12-02 18:29:06
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)) + geom_point(aes(colour= factor (group), size=z)) + theme_bw() I want make connect every points within

Manipulating axis titles in ggpairs (GGally)

折月煮酒 提交于 2019-12-02 17:46:50
I'm using the code below to generate the following chart. # Setup data(airquality) # Device start png(filename = "example.png", units = "cm", width = 20, height = 14, res = 300) # Define chart pairs.chrt <- ggpairs(airquality, lower = list(continuous = "smooth"), diag = list(continuous = "blank"), upper = list(continuous = "blank")) + theme(legend.position = "none", panel.grid.major = element_blank(), axis.ticks = element_blank(), axis.title.x = element_text(angle = 180, vjust = 1, color = "black"), panel.border = element_rect(fill = NA)) # Device off and print print(pairs.chrt) dev.off() I'm