scatter-plot

Change default colorbar for 3D scatter plot with matplotlib

跟風遠走 提交于 2021-02-19 08:25:19
问题 I have 3d coordinates defining positions of points in my 3D scatter plot with a corresponding number of values who I want to create a colour scale for representing the range of values as such: from mpl_toolkits.mplot3d import Axes3D fig = plt.figure() ax = fig.add_subplot(111, projection='3d') xs,ys,zs = np.random.random(50),np.random.random(50),np.random.random(50) values = np.random.random(50)*10 p = ax.scatter3D(xs, ys, zs=zs, c=values) cbar = fig.colorbar(p) cbar.cmap(plt.cm.Greys)

Add average lines for categorical scatterplots with single group values

安稳与你 提交于 2021-02-18 17:47:06
问题 I have a categorical scatter plot like this: which I generated in R with the following code (using the ggplot2 library): data <- runif(50, 13, 17) factors <- as.factor(sample(1:3, 50, replace = TRUE)) groups <- as.factor(sample(1:3, 50, replace = TRUE)) data_table <- data.frame(data, factors) g <- ggplot(data_table, aes(y = data_table[, 1], x = data_table[, 2], colour = groups)) + geom_point(size = 1.5) I am trying to add an average line for each x-group, but I can't manage to find the right

matplotlib Slow 3D scatter rotation

混江龙づ霸主 提交于 2021-02-18 10:47:06
问题 I am using matplotlib to scatter plot a 3D matrix of points. I am using the following code: import pylab as plt from mpl_toolkits.mplot3d import Axes3D import numpy as np my_data = np.random.rand(6500,3) # toy 3D points fig = plt.figure() ax = Axes3D(plt.gcf()) ax.scatter(my_data[:,0],my_data[:,1],my_data[:,2]) plt.show() It works, so it opens a window where I can see my points. However if I try to rotate the plot with the mouse (clicking and dragging it) it rotates REALLY slow. I think 6500

Connecting dots in a 2D scatterplot with a color as a third dimension

百般思念 提交于 2021-02-11 14:02:40
问题 Let's say I have the following dataset: x = np.arange(150000,550000,100000) y = np.random.rand(7*4) z = [0.6,0.6,0.6,0.6,0.7,0.7,0.7,0.7,0.8,0.8,0.8,0.8,0.9,0.9,0.9,0.9,1.0,1.0,1.0,1.0,1.1,1.1,1.1,1.1,1.2,1.2,1.2,1.2] x_ = np.hstack([x,x,x,x,x,x,x]) and I am doing a scatter plot: plt.figure() plt.scatter(x_,y,c=z) plt.colorbar() plt.set_cmap('jet') plt.xlim(100000,500000) plt.show() However, I would like to connect the dots of the same color. I tried just using plt.plot with the same

How calculate the area of a polygon in R, if I only have X,Y coordinates?

江枫思渺然 提交于 2021-02-11 12:17:22
问题 I have a data frame with X, Y coordinates, but I need to calculate the area that cover all the points in the scatterplot there is a way to draw a polygon that surround all the points and calculate this area? 回答1: This is a convex hull problem. Other questions cover similar territory. We can gather the plotting and area calculation problems here for good measure. To plot the convex hull of a point cloud, we can use the chull function: library(tidyverse) data <- tibble(x = runif(50), y = runif

Update marker shape of a scatter plot

ε祈祈猫儿з 提交于 2021-02-10 14:06:16
问题 A scatter plot object has a method called .set_color to update the colors of the markers and .set_offsets to update their position but how can I update the marker shapes? 回答1: A scatter plot returns a path collection, it contains the paths of the markers. In order to change the marker shape you need to set the path to the new marker path. For built-in markers, these paths can be obtained from the MarkerStyle class. For custom markers see my SO answer here. Example - scatter plot with dot

xlabel and ylabel values are not sorted in matplotlib scatterplot

走远了吗. 提交于 2021-02-10 12:06:54
问题 I have done tedious amounts of searching on the internet and it seems that I have not been able to figure out how to ask the right question to get the answer for what I want to do. I am trying to create a scatterplot with P/E ratio on the y-axis and Dividend Yield on the x-axis. I put the data into a CSV file and then imported each column into Python as individual lists. Here is how my scatterplot turns out below. I am confused why the x- and y- axes are not sorted numerically. I think I have

xlabel and ylabel values are not sorted in matplotlib scatterplot

試著忘記壹切 提交于 2021-02-10 12:04:37
问题 I have done tedious amounts of searching on the internet and it seems that I have not been able to figure out how to ask the right question to get the answer for what I want to do. I am trying to create a scatterplot with P/E ratio on the y-axis and Dividend Yield on the x-axis. I put the data into a CSV file and then imported each column into Python as individual lists. Here is how my scatterplot turns out below. I am confused why the x- and y- axes are not sorted numerically. I think I have

Altair adding date slider for interactive scatter chart pot

和自甴很熟 提交于 2021-02-08 05:54:06
问题 Has anyone tried using date as a slider for Altair interactive scatter plots? I'm trying to reproduce a similar plot to the gapminder scatter: 1) Instead of a year filter I'm trying to use a date e.g. '2020-01-05' and having the follow error: altair.vegalite.v4.schema.core.BindRange->max, validating 'type' '2020-05-17T00:00:00' is not of type 'number' 2) When I try to parse it as an int, nothing shows up in the plot 3) Examples of using the Year slider: https://www.datacamp.com/community

Plotting different clusters markers for every class in scatter plot

左心房为你撑大大i 提交于 2021-02-07 18:31:54
问题 I have a scatter plot where i am plotting 14 clusters, but each 2 clusters belong to the same class, they are all using the same markers. Every 50 rows is a cluster and every 100 rows is two clusters of the same class. What i want to do is change the markers for every 2 clusters or 100 rows. Link for the Data Frame import pandas as pd import numpy as np from matplotlib import pyplot as plt from matplotlib.pyplot import figure y = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,