scatter-plot

how to avoid overlapping labels with identical data points in scatterplot / ggplot?

最后都变了- 提交于 2019-12-21 04:58:11
问题 Is there any function etc which avoids overlapping data labels for identical data points in a scatter plot? I have checked the various questions/responses to textxy, direct.label, and geom_text(), but I haven't been successful. Maybe it's simply not possible. Here's a sample of the relevant data: structure(list(cowc = structure(c(5L, 7L, 24L, 24L, 23L, 36L, 34L, 38L, 23L, 6L, 8L, 38L, 38L, 23L, 5L, 7L, 24L, 24L, 23L, 36L, 34L, 38L, 23L, 6L, 8L, 38L, 38L, 23L), .Label = c("AFG", "ANG", "AZE",

How do I create a categorical scatterplot in R like boxplots?

拟墨画扇 提交于 2019-12-21 02:35:13
问题 Does anyone know how to create a scatterplot in R to create plots like these in PRISM's graphpad: I tried using boxplots but they don't display the data the way I want it. These column scatterplots that graphpad can generate show the data better for me. Any suggestions would be appreciated. 回答1: As @smillig mentioned, you can achieve this using ggplot2. The code below reproduces the plot that you are after pretty well - warning it is quite tricky. First load the ggplot2 package and generate

Excel XY Chart (Scatter plot) Data Label No Overlap

无人久伴 提交于 2019-12-21 01:43:28
问题 So I've been working on this for the past week. Although it can't do miracles, I can say I've got a pretty good result: I just wanted to put this code out there for all the poor souls like me that are looking for some kind of vba macro that helps them avoid label overlaps in a scatter plot, because while doing my research on the subject, I wasn't able to find anything helpful. 回答1: Const PIXEL_TO_POINT_RATIO As Double = 0.72 '1 Pixel = 72/96*1 Point Const tStep As Double = 0.1 Const rStep As

R - Smoothing color and adding a legend to a scatterplot

泪湿孤枕 提交于 2019-12-20 15:26:10
问题 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

Add points to the existing matplotlib scatter plot

自作多情 提交于 2019-12-20 05:32:11
问题 How to add points to the existing diagram? The straightforward solution is to plot a new scatter, adding new data. ax.scatter(data[:,0], data[:,1], cmap = cmap, c = color_data) ax.scatter(new_points_x, new_points_y, color='blue') But if we want to add more points with new colors, there is a problem: we have to take into consideration all previously added points. It would be great if I could use a special function like AddPoint(ax, new_point, color) I want only add new points in new colors. I

Add a legend to a ggplot2 scatter plot including additional lines

烈酒焚心 提交于 2019-12-20 04:48:02
问题 I would like to add a legend to a ggplot2 scatter graph which distinguishes between a regression line and a separate line I've added. For example, library(ggplot2) set.seed(123) data1=rnorm(1000,1,2) data2=rnorm(1000,1,4) DF=data.frame(data1,data2) ggplot(DF,aes(data1,data2))+geom_point(colour="dodgerblue",alpha=0.75)+geom_smooth(method=lm,se=F,aes(colour="Line of best fit"))+ geom_abline(intercept = 0, slope = 1, linetype="dashed", colour="black", alpha=1,size=1) There are two lines on this

Add a legend to a ggplot2 scatter plot including additional lines

你说的曾经没有我的故事 提交于 2019-12-20 04:47:14
问题 I would like to add a legend to a ggplot2 scatter graph which distinguishes between a regression line and a separate line I've added. For example, library(ggplot2) set.seed(123) data1=rnorm(1000,1,2) data2=rnorm(1000,1,4) DF=data.frame(data1,data2) ggplot(DF,aes(data1,data2))+geom_point(colour="dodgerblue",alpha=0.75)+geom_smooth(method=lm,se=F,aes(colour="Line of best fit"))+ geom_abline(intercept = 0, slope = 1, linetype="dashed", colour="black", alpha=1,size=1) There are two lines on this

nvd3 Bubble chart with log scale

北城余情 提交于 2019-12-20 02:46:13
问题 I am using NVD3 scatter/ Bubble chart. This is a continuation from the question here. I am plotting the log base 2 values for the y axis. But I want the y axis to have the original values as labels corresponding to the log base 2 scale. I am unable to understand how to do so. Edit This is what I have for plotting data[i].values.push({ x: random() , y: log2(yValue) , size: Math.random() }); function log2(val) { console.log("val = " + val + " : " + Math.log(val) / Math.LN2) return Math.log(val)

Plotting scatterplots with pairs in R, in log scale with data containing zeros

◇◆丶佛笑我妖孽 提交于 2019-12-20 01:38:59
问题 I am trying to plot some pairs of scatterplots using "pairs". My dataframe look like : >e X Y Z 0 0 0 2 3 4 0 3 4 3 3 3 A completely standard dataframe here. I use this to plot my scatter plots, again nothing fancy: pairs(~X+Y+Z, data=e, log="xy") It works great, but it doesn't plot the labels. However if I remove the log="xy" in the command, then the labels are plotted nicely. So I guess it has to do with the fact that I want my scatterplots to be in log scale. So my question is what shall I

Matplotlib Scatter plot filter color (Colorbar)

*爱你&永不变心* 提交于 2019-12-19 11:40:18
问题 I have some data let say x , y , and z . All are 1D arrays. I have done a scatter plot with z as color as; import matplotlib.pyplot as plt plt.scatter(x,y,c=z,alpha = 0.2) plt.xlabel("X") plt.ylabel("Y") plt.ylim((1.2,1.5)) plt.colorbar() The z values are normalized and its between -1 to 1 . I have attached the figure below. The question I have is; How can I filter the colors such that let say the points that have a color value between -0.25 to 0.25 disappear form the figure (i.e set the