scatter-plot

Add a legend to a ggplot2 scatter plot including additional lines

旧城冷巷雨未停 提交于 2019-12-02 04:11:34
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 plot, a red regression line, and a black line with equation y=x . I have managed to add a regression

Hide alternate lines in scatter chart coreplot

本秂侑毒 提交于 2019-12-02 03:57:58
Can we join alternate coordinates using line in coreplot -> scatter graph in ios ? In above picture suppose I want to join alternate points , what i mean is {0,0} - {1,6} will be joined {1,6} - {2,5} wont be joined {2,5} - {3,6} joined and so on ... Is this possible in coreplot ? Any help would be appreciated ! 来源: https://stackoverflow.com/questions/33259802/hide-alternate-lines-in-scatter-chart-coreplot

Update marker sizes of a scatter plot

断了今生、忘了曾经 提交于 2019-12-02 03:52:44
A scatter plot object has a method called .set_array to update the colours of the markers and .set_offsets to update their position but how can I update the marker sizes? I need this for fast real time plotting. CT Zhu Yes it is doable, with using a magic method ( _size ). Use it with caution, as it may become broken in future releases: from matplotlib import pyplot as plt import numpy as np x, y=range(10), range(10) sca=plt.scatter(x,y) raw_input() sca._sizes=(5+np.arange(10))*10 #you can set you markers to different sizes plt.draw() The method to update the sizes of the scatter points is

change y axis labels in nvd3 scatter-chart

╄→гoц情女王★ 提交于 2019-12-02 03:23:54
问题 I am trying to have my own y axis labels for the bubble chart in nvd3. Currently the labels are [1,2,3,4,5]. I want them to be displayed as [2,4,8,16,32]. I found the following function, chart.yAxis.tickValues(['2','4','8','16','32']); But the labels are not being changed here. I am unable to understand why. 回答1: These tick values will not have any effect if the y values themselves are not within the 2-32 range. Right now that chart only has y values up to 2+. So, if in addition to adding

change y axis labels in nvd3 scatter-chart

ぃ、小莉子 提交于 2019-12-02 02:20:22
I am trying to have my own y axis labels for the bubble chart in nvd3. Currently the labels are [1,2,3,4,5]. I want them to be displayed as [2,4,8,16,32]. I found the following function, chart.yAxis.tickValues(['2','4','8','16','32']); But the labels are not being changed here . I am unable to understand why. These tick values will not have any effect if the y values themselves are not within the 2-32 range. Right now that chart only has y values up to 2+. So, if in addition to adding chart.yAxis.tickValues(['2','4','8','16','32']); to the Chart Code/Javascript tab as you have in your question

nvd3 Bubble chart with log scale

笑着哭i 提交于 2019-12-01 21:01:47
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) / Math.LN2; } Now, the y axis ticks have the log2 values. I want to change the y axis ticks to have

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

感情迁移 提交于 2019-12-01 20:39:29
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 do? Shall I remove all lines with zeros in it before hand (how do you do that?) Is there a magic trick

wrong order in (matplotlib.pyplot) scatter plot axis [duplicate]

◇◆丶佛笑我妖孽 提交于 2019-12-01 20:14:08
This question already has an answer here: Plot sklearn LinearRegression output with matplotlib 1 answer I'm following this linear regression example but my result differs from what should be. The problem is in the plot axis, they are not in order. expected: my result: zoom to see the axis: The Code: import pandas as pd from sklearn import linear_model import matplotlib.pyplot as plt #read data dataframe = pd.read_fwf('brain_body.txt') x_values = dataframe[['Brain']] y_values = dataframe[['Body']] #train model on data body_reg = linear_model.LinearRegression() body_reg.fit(x_values, y_values)

creating legend for scatter3 plot (Matlab)

故事扮演 提交于 2019-12-01 19:04:03
I have a matrix points X in 3 dimensions ( X is a Nx3 matrix) and those points belong to clusters. The cluster it belongs is given by the Nx1 vector Cluster (it has values like 1,2,3,...). So, I am plotting it on scatter3 like this: scatter3(X(:,1),X(:,2),X(:,3),15,Cluster) It works fine, but I would like to add a legend to it, showing the colored markers and the cluster it represents. For example, if i have 3 clusters, I would like to have a legend like: <blue o> - Cluster 1 <red o> - Cluster 2 <yellow o> - Cluster 3 Thank you very much for the help! Jonas Instead of using scatter3 , I

Plotting multiple scatter plots pandas

試著忘記壹切 提交于 2019-12-01 16:12:47
I think there are many questions on plotting multiple graphs but not specifically for this case as shown below. The pandas documentation says to 'repeat plot method' to plot multiple column groups in a single axes. However, how would this work for 3 or more column groups? For example if we define a third column: bx = df.plot(kind='scatter', x='a',y='f',color = 'Green',label ='f') Where would this bx be passed into? Also, if the plot is the same graph, shouldn't the x-axis be consistently either 'a' or 'c'? but the documentation has 2 different x axis: 'a' and 'c' Where would this bx be passed