[英]Remove colorbar's borders matplotlib
How to remove the borders on the colorbar(or make them thinner)? 如何删除颜色条上的边框(或使它们更薄)?
I tried pretty much every combination of the following: 我几乎尝试了以下各种组合:
cb = plt.colorbar(im3,drawedges=False) #or True with next two lines
#cb.outline.set_linewidth(0)
#cb.dividers.set_linewidth(0)
cb.solids.set_rasterized(True)
cb.solids.set_edgecolor("face")
#Im saving as pdf
plt.savefig("thing.pdf",dpi=1000, bbox_inches='tight')
Some of these help when viewed with the matplotlib figure, but the saved pdf is even worse. 当使用matplotlib图查看时,其中一些有帮助,但保存的pdf更糟糕。
Setting cb.outline.set_visible()
to False
removes the outline, both in the figure and in the saved pdf. 将cb.outline.set_visible()
设置为False
将删除图中和保存的pdf中的轮廓。 I observed that setting the line's width to something small also was reflected in the output file. 我观察到将线宽设置为较小也反映在输出文件中。
import matplotlib.pyplot as plt
import numpy as np
data = np.random.rand(2,2)
im3 = plt.imshow(data)
cb = plt.colorbar(im3)
cb.outline.set_visible(False)
# this worked on matplotlib 1.3.1
#cb.outline.set_linewidth(0.05)
cb.set_ticks([])
#Im saving as pdf
plt.savefig("thing.pdf",dpi=1000, bbox_inches='tight')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.