2024-10-04 09:25:45 发布
网友
我想在matplotlib中的直方图条中添加白色的“中断”,这样网格线就可以在绘图中继续显示,而不会在背景中造成干扰或繁忙。我想看起来像下面这样:
我想要的-https://imgur.com/IUr3tz6
下面是要使用的测试直方图:
vals = np.random.randn(1000) f = plt.figure(figsize=[4,4]) ax = f.add_subplot(111) ax.hist(vals, bins=20, normed=True)
如果使网格线与背景颜色相同,并独立管理水平和垂直网格线,则可以获得所需的“视觉打断”。你知道吗
import numpy as np from matplotlib import pyplot as plt vals = np.random.randn(1000) f = plt.figure(figsize=\[4,4\]) ax = f.add_subplot(111) ax.hist(vals, bins=20, normed=True, ) ax.yaxis.grid(which="major", color='white', linestyle='-', linewidth=0.5) ax.xaxis.grid(which="major", color='white', linestyle='-', linewidth=4) plt.show()]
如果使网格线与背景颜色相同,并独立管理水平和垂直网格线,则可以获得所需的“视觉打断”。你知道吗
相关问题 更多 >
编程相关推荐