scatter

python pyplot: colorbar on contourf and scatter in same plot

坚强是说给别人听的谎言 提交于 2020-08-22 06:57:14
问题 I have two different datasets. One is a numpy NxM matrix and another is a Lx3 pandas dataframe. I am overlaying scatter plot (Lx3 dataframe) on top of a contour plot (NxM) and the colorbar is scaling based on the scatter plot data. How can I force the colorbar to scale based on both data sets (How can I synchronize the colorbar on both plot layers) ? import numpy as np import matplotlib.pyplot as plt #generate random matrix with min value of 1 and max value 5 xx = np.random.choice(a = [1,2,3

python pyplot: colorbar on contourf and scatter in same plot

僤鯓⒐⒋嵵緔 提交于 2020-08-22 06:56:47
问题 I have two different datasets. One is a numpy NxM matrix and another is a Lx3 pandas dataframe. I am overlaying scatter plot (Lx3 dataframe) on top of a contour plot (NxM) and the colorbar is scaling based on the scatter plot data. How can I force the colorbar to scale based on both data sets (How can I synchronize the colorbar on both plot layers) ? import numpy as np import matplotlib.pyplot as plt #generate random matrix with min value of 1 and max value 5 xx = np.random.choice(a = [1,2,3

Plotting scatter plot by groups in r

穿精又带淫゛_ 提交于 2020-08-08 06:27:08
问题 Is there any function in r that allows the plotting of this kind of scatter plots, which separates the dots by group? Here is what I have done so far: hours = c(0.00 ,-1.78 ,-0.50 ,-2.00 ,-2.80 ,2.00 ,-0.16 ,-0.34 ,1.00 ,1.00 ,2.00 ,-1.34 ,-1.00 ,-1.10 ,-0.43 ,-0.49 ,-0.02 ,-0.91, 0.48 ,2.33 ,1.00 ,0.00 ,1.18 ,1.29 ,-1.07 ,-0.26 ,1.96 ,0.36 ,2.00 ,-0.63 ,-0.80 ,-0.70 ,-2.00 ,1.17 ,0.67 ,-3.00) group = c(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2) df = data.frame

Python plotly scatter_geo modify hover data

折月煮酒 提交于 2020-07-22 14:19:40
问题 I want to modify hover data and leave ther for e.g. only bins data. I made following code, but hover_data parameter didn't work. What is the way to modify haver data? import plotly.express as px import plotly.graph_objs as go import pandas as pd rows=[['501-600','15','122.58333','45.36667'], ['till 500','4','12.5','27.5'], ['more 1001','41','-115.53333','38.08'], ] colmns=['bins','data','longitude','latitude'] df=pd.DataFrame(data=rows, columns=colmns) df = df.astype({"data": int}) fig=px

Python plotly scatter_geo modify hover data

荒凉一梦 提交于 2020-07-22 14:18:46
问题 I want to modify hover data and leave ther for e.g. only bins data. I made following code, but hover_data parameter didn't work. What is the way to modify haver data? import plotly.express as px import plotly.graph_objs as go import pandas as pd rows=[['501-600','15','122.58333','45.36667'], ['till 500','4','12.5','27.5'], ['more 1001','41','-115.53333','38.08'], ] colmns=['bins','data','longitude','latitude'] df=pd.DataFrame(data=rows, columns=colmns) df = df.astype({"data": int}) fig=px

Plot multiple y-axis AND colorbar in matplotlib

北慕城南 提交于 2020-06-26 04:25:06
问题 I am trying to produce a scatter plot that has two different y-axes and also a colorbar. Here is the pseudo-code used: #!/usr/bin/python import matplotlib.pyplot as plt from matplotlib import cm fig = plt.figure() ax1 = fig.add_subplot(111) plt.scatter(xgrid, ygrid, c=be, # set colorbar to blaze efficiency cmap=cm.hot, vmin=0.0, vmax=1.0) cbar = plt.colorbar() cbar.set_label('Blaze Efficiency') ax2 = ax1.twinx() ax2.set_ylabel('Wavelength') plt.show() And it produces this plot: My question is

Matplotlib: Automatically displaying time column as 2 hour ticks on y axis in scatterplot

我与影子孤独终老i 提交于 2020-06-23 09:07:22
问题 I have this data: Time = ['2017-03-13 00:01:00', '2017-03-13 00:02:00', '2017-03-13 23:59:00'] Speed = [20, 40.5, 100] Kilometer = [1.4, 2.0, 4.1] N130317 = pd.DataFrame({'Time':Time, 'Speed':Speed, 'Kilometer':Kilometer}) I have converted the time using: N130317['Time'] = pd.to_datetime(N130317['Time'], format = '%Y-%m-%d %H:%M:%S') N130317['Time'] = pd.to_datetime(N130317['Time'], format).apply(lambda x: x.time()) N130317['Time'] = N130317['Time'].map(lambda t: t.strftime('%H:%M')) I have

python - scatter plot with dates and 3rd variable as color

我只是一个虾纸丫 提交于 2020-04-30 07:37:30
问题 I am trying to plot an x-y plot, with x or y as date variable, and using a 3rd variable to color the points. I managed to do it if none of the 3 variables are date, using: ax.scatter(df['x'],df['y'],s=20,c=df['z'], marker = 'o', cmap = cm.jet ) After searching, I find out that for normal plot, we have to use plot_date(). Unfortunately, I haven't been able to color the points. Can anybody help me? Here is a small example: import matplotlib, datetime import matplotlib.pyplot as plt import

python - scatter plot with dates and 3rd variable as color

风格不统一 提交于 2020-04-30 07:37:08
问题 I am trying to plot an x-y plot, with x or y as date variable, and using a 3rd variable to color the points. I managed to do it if none of the 3 variables are date, using: ax.scatter(df['x'],df['y'],s=20,c=df['z'], marker = 'o', cmap = cm.jet ) After searching, I find out that for normal plot, we have to use plot_date(). Unfortunately, I haven't been able to color the points. Can anybody help me? Here is a small example: import matplotlib, datetime import matplotlib.pyplot as plt import