Skip to content

Instantly share code, notes, and snippets.

@basavyr
Created January 23, 2022 17:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save basavyr/763c0a578b2e5ab9cb6b324825a6864f to your computer and use it in GitHub Desktop.
Save basavyr/763c0a578b2e5ab9cb6b324825a6864f to your computer and use it in GitHub Desktop.
Create a plot label for a graph using `matplotlib` with relative positioning
fig, ax = plt.subplots()
x = []
y = []
plt.plot()
plt.xlabel()
plt.ylabel()
ax.legend(loc='best')
ax.set_title('')
plt.text(0.80, 0.20, '', horizontalalignment='center',verticalalignment='center', transform=ax.transAxes, fontsize=11)
plt.savefig('', bbox_inches='tight', dpi=300)
fig.tight_layout()
plt.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment