scatter-plot

scatterplot3d: regression plane with residuals

夙愿已清 提交于 2019-11-28 11:38:05
Using scatterplot3d in R, I'm trying to draw red lines from the observations to the regression plane: wh <- iris$Species != "setosa" x <- iris$Sepal.Width[wh] y <- iris$Sepal.Length[wh] z <- iris$Petal.Width[wh] df <- data.frame(x, y, z) LM <- lm(y ~ x + z, df) library(scatterplot3d) G <- scatterplot3d(x, z, y, highlight.3d = FALSE, type = "p") G$plane3d(LM, draw_polygon = TRUE, draw_lines = FALSE) To obtain the 3D equivalent of the following picture: In 2D, I could just use segments : pred <- predict(model) segments(x, y, x, pred, col = 2) But in 3D I got confused with the coordinates. Using

Using D3 transition method with data for scatter plot

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-28 10:57:29
So I'm new to D3 and have little exp with JavaScript in general. So I have been following some tutorials am currently using source code that creates a basic scatter plot. Now my question is how do I use the transition() method to moves the circles around when I add more datasets? I want to be able to set up buttons and when a user presses them, it activates the transition() method with the corresponding dataset. The tutorial I read on transitions only showed a transition on a single rectangle and did it manually, without data, and not with multiple items //Width and height var w = 900; var h =

Categorical scatter plot with mean segments using ggplot2 in R

你说的曾经没有我的故事 提交于 2019-11-28 10:35:35
I am trying to plot a simple scatter plot for 3 groups, overlaying a segment indicating the mean for each group and labelling the groups. I have managed to get a scatter plot with error bars, but I would only like a segment indicating where the mean is. I also cannot seem to be getting the group labelling right. To get the summary statistics I am using the function "summarySE" from this page . Is there any simpler way to do this, and to get a segment instead of a point for the mean? I really appreciate your help! library(ggplot2) library(plyr) df <- data.frame(tt = rep(1:3, each = 40), val =

How to assign colors to each value in scatter function - GNU Octave

末鹿安然 提交于 2019-11-28 10:08:52
问题 How can I use the scatter function in GNU Octave in order to assign colors to each plotted value ? 回答1: You have to change colormap and 4th parameter of octave's scatter. The parameter is vector 1xn indexing colormap. You can have maximally 255^3 vectors. And how to do that? Example solution: Set colormap (matrix 3 x n), which will contain each color exactly ones Use as 4th parameter vector, which is containing each number exactly ones, and has same size like x and y clf; x = randn (100, 1);

Multicolor scatter plot legend in Python

喜欢而已 提交于 2019-11-28 09:49:03
问题 I have some basic car engine size, horsepower and body type data (sample shown below) body-style engine-size horsepower 0 convertible 130 111.0 2 hatchback 152 154.0 3 sedan 109 102.0 7 wagon 136 110.0 69 hardtop 183 123.0 Out of which I made a scatter plot with horsepower on x axis, engine size on y axis and using body-style as a color scheme to differentiate body classes and. I also used "compression ratio" of each car from a seperate dataframe to dictate the point point size This worked

How to disable legend in nvd3 or limit it's size

倾然丶 夕夏残阳落幕 提交于 2019-11-28 09:42:32
I'm using nvd3 and have a few charts where the legend is much to large. E.g. a scatter/bubble with 15 groups and the group names are long. The legend is so large that it leaves almost no room for the chart itself. Is there a way to remove the legend or toggle the legend or limit the height/width it is taking up? Any example would be great. Also, is there a way to have the bubble show a descriptive string? Right now when you stand on top of a bubble it highlights the x/y coordinates. I also want it to show the bubble name. For example, each of my bubbles represents a country (which has a name),

pylab 3d scatter plots with 2d projections of plotted data

爷,独闯天下 提交于 2019-11-28 09:18:23
I am trying to create a simple 3D scatter plot but I want to also show a 2D projection of this data on the same figure. This would allow to show a correlation between two of those 3 variables that might be hard to see in a 3D plot. I remember seeing this somewhere before but was not able to find it again. Here is some toy example: x= np.random.random(100) y= np.random.random(100) z= sin(x**2+y**2) fig= figure() ax= fig.add_subplot(111, projection= '3d') ax.scatter(x,y,z) You can add 2D projections of your 3D scatter data by using the plot method and specifying zdir : import numpy as np import

Setting a fixed size for points in legend

十年热恋 提交于 2019-11-28 06:48:04
I'm making some scatter plots and I want to set the size of the points in the legend to a fixed, equal value. Right now I have this: import matplotlib.pyplot as plt import numpy as np def rand_data(): return np.random.uniform(low=0., high=1., size=(100,)) # Generate data. x1, y1 = [rand_data() for i in range(2)] x2, y2 = [rand_data() for i in range(2)] plt.figure() plt.scatter(x1, y1, marker='o', label='first', s=20., c='b') plt.scatter(x2, y2, marker='o', label='second', s=35., c='r') # Plot legend. plt.legend(loc="lower left", markerscale=2., scatterpoints=1, fontsize=10) plt.show() which

Can you explain why the plot is stopping at J (at index 10)

烈酒焚心 提交于 2019-11-28 05:08:45
问题 I am running this program to find the distribution of characters in a specific text. # this is a paragraph from python documentation :) mytext = 'When a letter is first k encountered, it is missing from the mapping, so the default_factory function calls int() to supply a default count of zero. The increment operation then builds up the count for each letter.The function int() which always returns zero is just a special case of constant functions. A faster and more flexible way to create

How to do a scatter plot with empty circles in Python?

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-28 02:53:11
In Python, with Matplotlib, how can a scatter plot with empty circles be plotted? The goal is to draw empty circles around some of the colored disks already plotted by scatter() , so as to highlight them, ideally without having to redraw the colored circles. I tried facecolors=None , to no avail. Gary Kerr From the documentation for scatter: Optional kwargs control the Collection properties; in particular: edgecolors: The string ‘none’ to plot faces with no outlines facecolors: The string ‘none’ to plot unfilled outlines Try the following: import matplotlib.pyplot as plt import numpy as np x =