def set_tayloraxes(fig, location): trans = PolarAxes.PolarTransform() r1_locs = np.hstack((np.arange(1, 10) / 10.0, [0.95, 0.99,1])) t1_locs = np.arccos(r1_locs) gl1 = grid_finder.FixedLocator(t1_locs) tf1 = grid_finder.DictFormatter(dict(zip(t1_locs, map(str, r1_locs)))) r2_locs = np.arange(0, 2, 0.2) #r2_labels = ['0 ', '0.25 ', '0.50 ', '0.75 ', 'REF ', '1.25 ', '1.50 ', '1.75 '] r2_labels = ['0 ', '0.2 ', '0.4 ', '0.6','0.8 ', 'REF ', '1 ', '1.2 ', '1.4 ','1.6 ', '1.8 ', '2 '] gl2 = grid_finder.FixedLocator(r2_locs) tf2 = grid_finder.DictFormatter(dict(zip(r2_locs, map(str, r2_labels)))) ghelper = floating_axes.GridHelperCurveLinear(trans, extremes=(0, np.pi / 2, 0,2), grid_locator1=gl1, tick_formatter1=tf1, grid_locator2=gl2, tick_formatter2=tf2) ax = floating_axes.FloatingSubplot(fig, location, grid_helper=ghelper) fig.add_subplot(ax) ax.axis["top"].set_axis_direction("bottom") ax.axis["top"].toggle(ticklabels=True, label=True) ax.axis["top"].major_ticklabels.set_axis_direction("top") ax.axis["top"].label.set_axis_direction("top") ax.axis["top"].label.set_text("Correlation") ax.axis["top"].label.set_fontsize(14) ax.axis["left"].set_axis_direction("bottom") ax.axis["left"].label.set_text("Standard deviation") ax.axis["left"].label.set_fontsize(14) ax.axis["right"].set_axis_direction("top") ax.axis["right"].toggle(ticklabels=True) ax.axis["right"].major_ticklabels.set_axis_direction("left") ax.axis["bottom"].set_visible(False) ax.grid(True) polar_ax = ax.get_aux_axes(trans) rs, ts = np.meshgrid(np.linspace(0, 2, 100), np.linspace(0, np.pi / 2, 100)) rms = np.sqrt(1 + rs ** 2 - 2 * rs * np.cos(ts)) CS = polar_ax.contour(ts, rs, rms, colors='gray', linestyles='--') plt.clabel(CS, inline=1, fontsize=10) t = np.linspace(0, np.pi / 2) r = np.zeros_like(t) + 1 polar_ax.plot(t, r, 'k--') polar_ax.text(np.pi/2+0.032,1.02, " 1.00", size=10.3,ha="right", va="top", bbox=dict(boxstyle="square",ec='w',fc='w')) return polar_ax这段函数中如何让虚线中的数字消失
时间: 2023-06-20 07:07:20 浏览: 368
要让虚线中的数字消失,可以将contour函数调用时的参数inline设置为False,即:
CS = polar_ax.contour(ts, rs, rms, colors='gray', linestyles='--', inline=False)
然后在调用clabel函数时也需要将inline设置为False:
plt.clabel(CS, inline=False, fontsize=10)
这样就可以让虚线中的数字消失了。
阅读全文