scatter-plot

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

偶尔善良 提交于 2019-11-29 20:38:40
问题 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 回答1: 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

multiple scatter plots with matplotlib and strings on the x-axis.

China☆狼群 提交于 2019-11-29 18:13:52
I'm trying to make three scatter plots in one figure. I tried it this way. Do an import first. import matplotlib.pyplot as plt Define the variables and make one figure that contains three scatter plots. c_pop = [0.410, -0.094, -0.111, -0.106, -0.090, 0.070, -0.043, -0.181, 0.221] c_labels = ['ll120', 'll123', 'll124', 'll27', 'll28', 'll30', 'll446, n12', 'll447, n86', 'll471'] pre_lo = [-0.493] post_lo = [0.145] lo_label = ['lo'] fig = plt.figure() ax1 = fig.add_subplot(111) ax1.scatter(c_labels, c_pop, color='black') ax1.scatter(lo_label, pre_lo, color='green', label='pre-SNEP') ax1.scatter

Multicolor scatter plot legend in Python

大兔子大兔子 提交于 2019-11-29 15:52:13
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 out well except I cant display color legends for my plot. Help needed as i'm a beginner. Here's my code:

How do we plot images at given coordinates in R?

久未见 提交于 2019-11-29 15:45:38
问题 Given 'n' images in a png/jpeg format and 'n' corresponding coordinates in 2 dimensions (x,y): I would like to plot these images at the given coordinates on a single plot. If I find the images to be too big, I would ideally like to plot them as a smaller/scaled version at the given coordinates. How can i achieve such a plot in R? An example of how such a plot would look is given below: 回答1: xy <- data.frame(x=runif(10, 0, 100), y=runif(10, 0, 100)) require(png) img <- readPNG(system.file("img

Matplotlib Scatter plot change color based on value on list

白昼怎懂夜的黑 提交于 2019-11-29 15:03:07
I'm quite new to matplotlib and i would like to know how we can change color of points on a scatter plot based on the value in a list. In fact, I have a 2-D array that I want to plot and a list with the same number of rows containing, for each point, the color we want to use. #Example data = np.array([4.29488806,-5.34487081], [3.63116248,-2.48616998], [-0.56023222,-5.89586997], [-0.51538502,-2.62569576], [-4.08561754,-4.2870525 ], [-0.80869722,10.12529582]) colors = ['red','red','red','blue','red','blue'] ax1.plot(data[:,0],data[:,1],'o',picker=True) How to set the color parameter to fit my

Multiple data in scatter matrix

十年热恋 提交于 2019-11-29 14:02:56
问题 Is it possible to add multiple data to a pandas.tools.plotting.scatter_matrix and assigning a color to each group of data? I'd like to show the scatter plots with data points for one group of data, let's say, in green and the other group in red in the very same scatter matrix. The same should apply for the density plots on the diagonal. I know that this is possible by using matplotlib's scatter function, but that does not give me a scatter matrix. The documentation of pandas is mum on that.

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

让人想犯罪 __ 提交于 2019-11-29 11:44:09
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 constant functions is to use a lambda function which can supply any constant value (not just zero):' d =

Scatterplot with different size, marker, and color from pandas dataframe

我与影子孤独终老i 提交于 2019-11-29 10:39:34
I am trying to do a scatter plot with speed over meters for each point where marker indicate different types, size indicate different weights and color indicate how old a point is over 10 minutes scale. However, I was only able to plot by size so far. Any help is highly appreciated. x = {'speed': [10, 15, 20, 18, 19], 'meters' : [122, 150, 190, 230, 300], 'type': ['phone', 'phone', 'gps', 'gps', 'car'], 'weight': [0.2, 0.3, 0.1, 0.85, 0.0], 'old': [1, 2, 4, 5, 8]} m = pd.DataFrame(x) plt.scatter(m.meters, m.speed, s = 30* m.weight) mkr_dict = {'gps': 'x', 'phone': '+', 'car': 'o'} meters speed

Colormap for errorbars in x-y scatter plot using matplotlib

ⅰ亾dé卋堺 提交于 2019-11-29 09:23:16
I have a time series of data for which I have the quantity, y, and its error, yerr. I would now like to create a plot that shows y against phase (i.e. time / period % 1) with vertical errorbars (yerr). For this, I typically use pyplot.errorbar(time, y, yerr=yerr, ...) However, I would like to use a colorbar/map to indicate the value of time in this same plot. What I thus do is the following: pylab.errorbar( phase, y, yerr=err, fmt=None, marker=None, mew=0 ) pylab.scatter( phase, y, c=time, cmap=cm ) Unfortunately, this will plot unicolored errorbars (default is blue). Since I have ~1600 points

Change ylab position in R Scatterplot3D

痴心易碎 提交于 2019-11-29 09:19:29
问题 I´m working with R scatterplot3D and I need to use expression() in labels because I have to use some Greek letters; my question is: is there a way to pull the y.lab name down or write it along the axis (in a diagonal position)? I went to help and packages description but nothing seems to work; thanks in advance for any help Maria library(scatterplot3d) par(mfrow=c(1,1)) A <- c(3,2,3,3,2) B <- c(2,4,5,3,4) D <- c(4,3,4,2,3) scatterplot3d(A,D,B, xlab=expression(paste(x[a],"-",x[b])), ylab