matplotlib

How to pass RGBA color into Seaborn PairGrid

安稳与你 提交于 2021-02-05 09:28:05
问题 I have defined a PairGrid function, which works fine grid = sns.PairGrid(data= df, vars = ['sugarpercent', 'pricepercent', 'winpercent'], size = 3) # Map the plots to the locations grid = grid.map_upper(plt.scatter, color = 'darkred') grid = grid.map_upper(corr) grid = grid.map_upper(sns.regplot, line_kws={'color': 'darkred'}, lowess=True) However, I want to use RGBA (12, 50, 196, 0.6) instead of darkred for both scatter and regplot function. I tried to replace the tuple 'color': (12, 50, 196

Altering height range of matplotlib histogram2d

限于喜欢 提交于 2021-02-05 09:11:41
问题 I am trying to plot some 2D empirical probability distributions using matplotlib's histogram2d. I want the colours to be on the same scale across several different plots, but cannot find a way to set a scale even if I know a global upper and lower bound on the resulting distribution. As is, each color scale will run from the minimum height to the maximum height of the histogram bins, but this range will be different for each plot. One potential solution would be to force one bin to take the

Catplot with Seaborn, side by side

|▌冷眼眸甩不掉的悲伤 提交于 2021-02-05 08:41:54
问题 I'm using this code below to plot a catplot with Seaborn. Its working ok. sns.catplot(data=df_gol, x='MODALIDADE_DO_VOO', y='VALOR',row='DESTINO', kind='box',height=3, aspect=1, color='red') But I am getting each box-plot stacked. I'd like to plot it side by side. How can I do that? My DF (df_gol) has these values: Column DESTINO - ['JPA', 'FOR', 'SSA', 'AJU'] Column MODALIDADE_DO_VOO - ['Direto', '1 parada'] Columns VALOR is float type I've been looking for some examples but I didn't

Python: plotting multiple plots in the same window

試著忘記壹切 提交于 2021-02-05 08:41:15
问题 I am trying to use what I learned from plotting multiple plots but whith offset ranges python, but I can't seem to make the appropriate adjustments for my Legendre plotting code: import numpy as np import pylab from numpy.polynomial.legendre import leggauss, legval def f(x): if 0 <= x <= 1: return 1 if -1 <= x <= 0: return -1 f = np.vectorize(f) deg = 1000 x, w = leggauss(deg) # len(x) == deg L = np.polynomial.legendre.legval(x, np.identity(deg)) integral = (L * (f(x) * w)[None,:]).sum(axis=1

How to calculate the angle of ellipse Gaussian distribution

无人久伴 提交于 2021-02-05 08:40:16
问题 I make following Python Code to calculate center and size of Gaussian-like distribution basis of moment method. But, I can't make the code to calculate the angle of gaussian. Please look at pictures. First Picture is original data. Second picture is reconstruct data from the result of moment method. But, second picture is insufficient reconstruction. Because, original data is inclined distribution. I have to, I think, calculate the angle of axis for Gaussian-like distribution. To assume that

Catplot with Seaborn, side by side

北城余情 提交于 2021-02-05 08:38:09
问题 I'm using this code below to plot a catplot with Seaborn. Its working ok. sns.catplot(data=df_gol, x='MODALIDADE_DO_VOO', y='VALOR',row='DESTINO', kind='box',height=3, aspect=1, color='red') But I am getting each box-plot stacked. I'd like to plot it side by side. How can I do that? My DF (df_gol) has these values: Column DESTINO - ['JPA', 'FOR', 'SSA', 'AJU'] Column MODALIDADE_DO_VOO - ['Direto', '1 parada'] Columns VALOR is float type I've been looking for some examples but I didn't

Map a specific string value to a specific color in matplotlib.pyplot.imshow()

五迷三道 提交于 2021-02-05 08:32:14
问题 I have a pandas.dataframe that looks like this: columns 0 1 2 3 4 5 A A A A B B B B B C C D D D E E F F I want to plot this using pyplot.imshow() , specifying the following colormap: color_dict = { "A": "#DA291E", "B": "#83DF39", "C": "#E8132d", "D": "#008933", "E": "#006CB3", "F": "#52BFEC" } If I was plotting a bar or a scatter I could just call with the argument color=a_list_of_colors but this doesn't work with imshow() . Instead I need to call with a cmap but as far as I understand it isn

Map a specific string value to a specific color in matplotlib.pyplot.imshow()

可紊 提交于 2021-02-05 08:30:07
问题 I have a pandas.dataframe that looks like this: columns 0 1 2 3 4 5 A A A A B B B B B C C D D D E E F F I want to plot this using pyplot.imshow() , specifying the following colormap: color_dict = { "A": "#DA291E", "B": "#83DF39", "C": "#E8132d", "D": "#008933", "E": "#006CB3", "F": "#52BFEC" } If I was plotting a bar or a scatter I could just call with the argument color=a_list_of_colors but this doesn't work with imshow() . Instead I need to call with a cmap but as far as I understand it isn

Matplotlib square major/minor grid for axes with different limits

巧了我就是萌 提交于 2021-02-05 08:15:07
问题 I have a plot with a background grid. I need grid cells to be square (both major grid and minor grid cells) even though the limits of X and Y axes are different. My current code is as follows: import matplotlib.pyplot as plt import matplotlib.ticker as plticker import numpy as np data = [0.014, 0.84, 0.95, -0.42, -0.79, 0.84, 0.98, 1.10, 0.56, -0.49] fig, ax = plt.subplots(figsize=(20, 5)) ax.minorticks_on() # Set major and minor grid lines on X ax.set_xticks(np.arange(0, 10, 0.2)) ax.xaxis

Matplotlib: Turning axes off and setting facecolor at the same time not possible?

前提是你 提交于 2021-02-05 08:13:27
问题 can someone explain why this simple code wont execute the facecolor command while setting the axis off? fig = plt.figure(1) ax = fig.add_subplot(211, facecolor=(0,0,0), aspect='equal') ax.scatter(np.random.random(10000), np.random.random(10000), c="gray", s=0.25) ax.axes.set_axis_off() Thanks in advance! 回答1: The background patch is part of the axes. So if the axes is turned off, so will the background patch. Some options: Re-add the background patch ax = fig.add_subplot(211, facecolor=(0,0,0