python - matplotlib how to correctly plot text in subplot -
this question has answer here:
this image plot using:
subplot(1,2,1) hist(...) subplot(1,2,2) text(...)
but don't want border of second plot , want text on upper left of plot. how can make it?
try this:
subplot(1,2,1) hist(...) ax2 = subplot(1,2,2) ax2.set_xticks([]) ax2.set_yticks([]) spine in ax2.spines.values(): spine.set_visible(false) ax2.invert_yaxis() ax2.text(..., verticalalignment="top")
update:
as pointed out in comments, can do:
subplot(1,2,1) hist(...) ax2 = subplot(1,2,2) ax2.axis("off") ax2.invert_yaxis() ax2.text(..., verticalalignment="top")
although remove default axis background (depending on settings , matplotlib version, may leave gray background color).
Comments
Post a Comment