0

我有一个考拉数据框。我想绘制一个直方图,但我想用一个 RGB 元组(r,g,b)来改变颜色。我怎样才能改变下面的代码来做到这一点?

import databricks.koalas as ks
import pandas as pd
import numpy as np
import random
random.seed(12345)
RGB = (172,8,14) # or RGB = (172/255,8/255,14/255)
pdf = pd.DataFrame(np.random.normal(size=(100000,1)), columns = ["x"])
kdf = ks.from_pandas(pdf)
kdf.hist(title='How do I change the color to RGB?', bins=50, legend = False)

在此处输入图像描述

4

1 回答 1

0

我想到了!

import databricks.koalas as ks
import pandas as pd
import numpy as np
import random
from matplotlib.colors import ListedColormap
random.seed(12345)
RGB = np.array([172/255,8/255,14/255])
pdf = pd.DataFrame(np.random.normal(size=(100000,1)), columns = ["x"])
kdf = ks.from_pandas(pdf)
kdf.hist(title='There! I changed the color!', bins=50, legend = False, colormap= ListedColormap(RGB))

在此处输入图像描述

于 2019-11-06T15:45:27.703 回答