gpt4 book ai didi

python - Matplotlib/Seaborn 中的颜色无法正常工作

转载 作者:行者123 更新时间:2023-12-01 08:38:19 34 4
gpt4 key购买 nike

我目前正在使用 Jupyter Notebooks 和 Python 3.6。我的 Matplotlib 版本 = 2.1.0 和 Seaborn = 0.8。

我正在尝试创建一个简单的直方图,但我选择的颜色没有正确显示。我已经尝试过名称和十六进制代码,但它们仍然关闭。当我运行下面的命令时,如果它呈浅紫色。这是一个错误吗?

df = pd.DataFrame({'Amt':[59119.01,52689.11,54463.54,45012.8,53420.47,  334039.49,  94835.81,   40249.92,   60778.5,    131089.66,  159300.51,  37420.23,   109027.39,  46517.16,   31111.03,   28460.97,   55727.89,   23697.92,   128070.98,  113071.94,  16434.57,   47017.19,   27298.45,   91567.64,   72149.69,   47008.25,   63433.26,   57974.05,   46005.38,   20523.73,   41667.67,   44363.23,   31643.49,   34950.89,   38749.02,   37020.86,   66763.92,   2213.25,    50885.14,   32082.28,   49402.86,   73664.92,   176837.44,  52419.13,   174972.64,  35696.26,   67633.75,   10155.15,   91313.78,   60905.62,   173246.79,  74650.25,   49870.63,   111247.15,  96744.08,   158676.63,  78737.52,   40902.64,   81754.59,   69576.24,   80367.22,   42069.36,   34225.93,   88640.63,   71082.48,   82383.45,   178614.79,  66045.65,   568349.26,  48430.81,   61056.6,    62891.76,   38144.68,   51772.81,   41275.36,   19806.93,   56705.53,   77288.84,   56193.58,   31577.68,   43604.02,   159297.04,  44421.67,   124023.53,  121095.64,  52458.05,   84144.68,   19733.8,    58783.62,   33843.9,    92353.17,   40333.5,    33963.21,   61753.04,   115071.75,  67826.43,   13759.06,   69503.46,   122834.22,  36221.76,   43099.89,   69486.09,   84977.88,   150496.42,  37529.24,   65556.82,   34542.54,   194334.82,  41509.68,   63752.19,   15131.41,   268516.89,  39878.7,    51318.55,   32804.47,   88286.19,   58257.96,   51147.62,   198729.71,  23717.35,   37948.9,    65643.99,   29169.85,   52104.09,   155064.46,  189166.26,  224709.54,  28435.69,   122461.49,  58699.17,   172621.65,  30362.56,   25906.69,   139623.36,  57947.78,   146286.72,  63071.56,   94105.7,    38775,  36829.24,   46915.13,   64921.71,   19821.47,   54941.86,   27611.53,   229861.94,  132863.47,  26790.18,   14773.49,   46014.17,   49295.85,   132955.36,  40243.87,   81203.09,   49036.49,   26821.14,   30539.79,   66860.03,   85590.2,    39937.06,   55457.55,   154109.62,  340755.24,  146253.58,  67437.54,   36887.4,    160900.65,  276748.53,  95847.25,   141842.67,  3778.83,    84342.49,   50993.42,   112417.17,  202245.29,  281826.99,  344341.41,  49804.82,   46844.19,   50769.7,    105665.49,  75205.52,   62543.11,   26754.09,   128714.07,  42136.78,   210658.16,  32719.59,   59456.49,   112240.95,  62186.83,   25147.86,   49889.56,   117047.29,  116211.71,  86987.11,   38831.68,   32607.09,   89794.67,   110604.86,  103216.11,  96880.91,   55828.93,   72206.18,   39613.95,   50643.06,   98660.3,    81873.18,   57271.32,   364857.64,  40736.48,   43278.65,   26941.55,   106942.73,  47070.25,   105976.73,  86639.71,   31996.6,    27553.69,   50550.97,   71275.6,    40731.26,   148965.66,  73834.95,   159077.11,  91472.48,   97271.17,   92710.73,   49582.7,    43037.83,   77664.19,   97275.49,   76277.6,    56653.04,   39106.11,   45673.98,   173585.38]})
fig = plt.figure()
ax = fig.add_axes([0,0,1,1])
fig = sns.distplot(df['Amt'],kde=False, color='darkblue',
bins=50 , hist_kws=dict(edgecolor="black", linewidth=2))

最佳答案

您看到的颜色实际上是您指定的颜色的透明版本。要将透明度设置回不透明,请将 alpha=1 添加到直方图参数。

fig = sns.distplot(df['Amt'],kde=False, bins=50 , color='darkblue',  
hist_kws=dict(edgecolor="black", linewidth=2, alpha=1))

enter image description here

关于python - Matplotlib/Seaborn 中的颜色无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53600460/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com