This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fig=plt.figure() | |
## AXES HANDLE | |
ax=fig.add_axes(mpltr.Bbox([[ .14 , .14 ],[ .90 , .92 ]])) | |
## COLORBAR AXES HANDLE | |
cx=fig.add_axes(mpltr.Bbox([[ .91 , .14 ],[ .93 , .92 ]])) | |
... | |
## PLOT THE STUFF YOU WANT | |
ax.contourf(X, Y, Z, etc... ) | |
... | |
## COLORBAR | |
cb=plt.colorbar(cf, cax=cx) | |
plt.figtext(.91, .92, (r"Variable Z"), va='bottom', ha='left') | |
... |
Another way is to use the set_title or the set_xlabel of your colorbar axes. For the first:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
## COLORBAR | |
cb=plt.colorbar(cf, cax=cx) | |
cx.set_title(r"Variable Z") | |
... |
However in this way I don't know how to set the title at a distance from the axes. For the second, this can be done using the labelpad:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
## COLORBAR | |
cb=plt.colorbar(cf, cax=cx) | |
cx.set_xlabel(r"Variable Z", labelpad=10) | |
cx.xaxis.set_label_position('top') | |
... |