4
Matplotlib에서 플롯하고있는 윤곽선의 선 두께와 별도로 내 색상 막대에 나타나는 선 두께를 편집하려고합니다. 등고선 선의 폭을 0.5로 설정하고 싶지만 색상 막대에서 색상 윤곽을 볼 수 없습니다. 등고선 선폭을 1.5로 설정하면 색상 막대에서 볼 수 있지만 윤곽선이 너무 두껍습니다. Python Matplotlib : 컬러 바 틱 변경 너비
import matplotlib.pyplot as plt
import matplotlib.mlab as mlab
import numpy as np
#get data
delta = 0.025
x = np.arange(-3.0, 3.0, delta)
y = np.arange(-3.0, 3.0, delta)
X, Y = np.meshgrid(x, y)
Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
Z = 10.0 * (Z2 - Z1)
#get contour levels
levels=[-1.5,-1.25,-1,-0.75,-0.5,-0.25,0,0.25,0.5,0.75,1,1.25,1.5]
fig = plt.figure()
ax = fig.add_subplot(111)
#plot contours and color bar
CS = plt.contour(X,Y,Z,levels, linestyles='solid', linewidths=0.5, extent=(-3,3,-3,3))
plt.clabel(CS, colors='black', inline=True, inline_spacing=0, fontsize=8)
CB = plt.colorbar(CS, aspect=35, shrink=0.5, pad=0.09, orientation='horizontal', extend='both')
CB.set_ticks(levels)
CB.set_label('(values)',size=8)
CB.ax.tick_params(labelsize=6)
#set plot limits
plt.xlim([-3,3])
plt.ylim([-3,3])
#set aspect ratios to be equal
plt.axes().set_aspect('equal')
#set ticks of plot
ax.xaxis.set_major_locator(plt.MultipleLocator(1.0))
ax.yaxis.set_major_locator(plt.MultipleLocator(1.0))
plt.xticks(fontsize=8)
plt.yticks(fontsize=8)
plt.show()
내가 윤곽 선폭과 년 Colorbar 선폭을 개별적으로 제어 할 수있는 방법에 대한 아이디어?
여기 디자인 선택과 싸우고있는 것 같습니다. – tacaswell
아, 그게 다예요. 올바른 방향으로 나를 가리켜 주셔서 감사 드리며 중복 된 것에 대해 유감스럽게 생각합니다. 수정 사항은 입니다. CB.ax.get_children() [4] .set_linewidths (1.5) – bsf10