scatter-plot

Using Conditional Statements to Change the Color of Data Points

风流意气都作罢 提交于 2019-12-01 03:51:37
问题 I have a data set, which I have used to make a scatter plot and I would like to assign three different colors to the data points within three different regions, based on their x values. Data points with x-values < 3 I want to appear red Data points with x-values (3,1549) I want to appear black Data points with x values >1549 I want to appear purple Here is my code for the scatterplot and accomplishing the first two parameters, how might I implement the third parameter, so that the last region

Interactive selection in ggplotly with geom_hex() scatterplot

廉价感情. 提交于 2019-12-01 03:23:17
I am trying to create a scatterplot matrix with interactive selection between geom items in individual matrix plots. This works when I am dealing with geom_points (inside ggpairs()). When a user selects points in any of the 3 bottom-left individual matrix plots, then they can see the points highlighted in the other matrix plots. Below is a simple example: library(GGally) library(ggplot2) library(plotly) dat = mtcars[,1:3] p <- ggpairs(dat) ggplotly(p) However, in my case, I am aiming to use geom_hex instead of geom_points. I am hoping to develop a way that a user can highlight a hexagon(s) in

How to pick a point in a subplot and highlight it in adjacent subplots in matplotlib(extension to region of points)

∥☆過路亽.° 提交于 2019-12-01 01:26:48
I want to create a scatter plot matrix which will be composed by some subplots. I have extracted from a .txt file my data and created an array of shape (x,y,z,p1,p2,p3). The first three columns of the array represent the x,y,z coordinates from the original image that these data come from and the last three columns(p1, p2, p3) some other parameters. Consequently, in each row of the array the parameters p1, p2, p3 have the same coordinates(x,y,z).In the scatter plot, I want to visualize the p1 parameter against the p2, p3 parameters in a first stage. For every point I pick, I would like its (x,y

Interactive selection in ggplotly with geom_hex() scatterplot

风流意气都作罢 提交于 2019-12-01 00:32:04
问题 I am trying to create a scatterplot matrix with interactive selection between geom items in individual matrix plots. This works when I am dealing with geom_points (inside ggpairs()). When a user selects points in any of the 3 bottom-left individual matrix plots, then they can see the points highlighted in the other matrix plots. Below is a simple example: library(GGally) library(ggplot2) library(plotly) dat = mtcars[,1:3] p <- ggpairs(dat) ggplotly(p) However, in my case, I am aiming to use

Scatterplot: Error in FUN(X[[i]], …) : object 'Group' not found

ぐ巨炮叔叔 提交于 2019-12-01 00:07:07
问题 I'm trying to plot some data using ggplot and I'm having some problems with the significant lines and asterisk. This is the code I am using: p <- ggplot(Hematoxilin_tumor_necrosis, aes(x=total, y=necro, colour = Group))+ labs(y="Necrotic area",x="Total area")+ theme_minimal() path = data.frame(x=c(78,79,79,78),y=c(22,22,34,34)) p + geom_point(size=0.7)+ geom_smooth(method=lm, se = F, size=0.8) + scale_color_manual(values=c("#999999","#333333"))+ #Adding asterisks geom_path(data = path, aes(x

Matplotlib: scatter plot with colormaps for edgecolor but no facecolor

时光毁灭记忆、已成空白 提交于 2019-11-30 21:03:55
I want to have a scatter plot with colormap for edgecolors but no facecolors. When I use facecolor='None' , it does not work. import numpy as np import matplotlib.pyplot as plt N = 50 x = np.random.rand(N) y = np.random.rand(N) colors = np.random.rand(N) area = np.pi * (15 * np.random.rand(N))**2 # 0 to 15 point radii plt.scatter(x, y, s=area,c=colors,facecolors='None',cmap="gist_rainbow", alpha=0.5) plt.show() Any solution? The c argument will affect facecolor and edgecolor simultaneouly, the arguments facecolor and edgecolor are hence ignored. A solution would be not to use the c argument

d3.v3 scatterplot with all circles the same radius

自古美人都是妖i 提交于 2019-11-30 16:08:39
问题 Every example I have found shows all of the scatter plot points to be of random radii. Is it possible to have them all the same size? If I try to statically set the radius all of the circles will be very small (I'm assuming the default radius). However, if I use Math.random() as in most examples there are circles large and small. I want all the circles to be large. Is there a way to do that? Here's the code snippet forming the graph data using Math.random() (this works fine for some reason):

draw a smooth polygon around data points in a scatter plot, in matplotlib

别说谁变了你拦得住时间么 提交于 2019-11-30 14:54:30
I have a bunch of cross plots with two sets of data and have been looking for a matploltib way of highlighting their plotted regions with smoothed polygon outlines. At the moment i just use Adobe Illustrator and amend saved plot, but this is not ideal. Example: I'd be grateful for any pointers/links to examples. Cheers Pablo Here, you have an example. I was written the main ideas, but obviously, you could do it better. A short explanations: 1) You need to compute the convex-hull ( http://en.wikipedia.org/wiki/Convex_hull ) 2) With the hull, you could scale it to keep all your data inside. 3)

Matplotlib 3D Scatter Plot with Colorbar

巧了我就是萌 提交于 2019-11-30 14:32:45
问题 Borrowing from the example on the Matplotlib documentation page and slightly modifying the code, import numpy as np from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt def randrange(n, vmin, vmax): return (vmax-vmin)*np.random.rand(n) + vmin fig = plt.figure() ax = fig.add_subplot(111, projection='3d') n = 100 for c, m, zl, zh in [('r', 'o', -50, -25), ('b', '^', -30, -5)]: xs = randrange(n, 23, 32) ys = randrange(n, 0, 100) zs = randrange(n, zl, zh) cs = randrange(n, 0,

How to label bubble chart/scatter plot with column from pandas dataframe?

坚强是说给别人听的谎言 提交于 2019-11-30 13:25:56
问题 I am trying to label a scatter/bubble chart I create from matplotlib with entries from a column in a pandas data frame. I have seen plenty of examples and questions related (see e.g. here and here). Hence I tried to annotate the plot accordingly. Here is what I do: import matplotlib.pyplot as plt import pandas as pd #example data frame x = [5, 10, 20, 30, 5, 10, 20, 30, 5, 10, 20, 30] y = [100, 100, 200, 200, 300, 300, 400, 400, 500, 500, 600, 600] s = [5, 10, 20, 30, 5, 10, 20, 30, 5, 10, 20