Skip to content

mep12 on multiline.py #4868

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 5, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 21 additions & 25 deletions examples/pylab_examples/multiline.py
Original file line number Diff line number Diff line change
@@ -1,44 +1,40 @@
#!/usr/bin/env python
from pylab import *
#from matplotlib.pyplot import *
#from numpy import arange

if 1:
figure(figsize=(7, 4))
ax = subplot(121)
ax.set_aspect(1)
plot(arange(10))
xlabel('this is a xlabel\n(with newlines!)')
ylabel('this is vertical\ntest', multialignment='center')
#ylabel('this is another!')
text(2, 7, 'this is\nyet another test',
import matplotlib.pyplot as plt
import numpy as np

plt.figure(figsize=(7, 4))
ax = plt.subplot(121)
ax.set_aspect(1)
plt.plot(np.arange(10))
plt.xlabel('this is a xlabel\n(with newlines!)')
plt.ylabel('this is vertical\ntest', multialignment='center')
plt.text(2, 7, 'this is\nyet another test',
rotation=45,
horizontalalignment='center',
verticalalignment='top',
multialignment='center')

grid(True)
plt.grid(True)

subplot(122)
plt.subplot(122)

text(0.29, 0.7, "Mat\nTTp\n123", size=18,
plt.text(0.29, 0.7, "Mat\nTTp\n123", size=18,
va="baseline", ha="right", multialignment="left",
bbox=dict(fc="none"))

text(0.34, 0.7, "Mag\nTTT\n123", size=18,
plt.text(0.34, 0.7, "Mag\nTTT\n123", size=18,
va="baseline", ha="left", multialignment="left",
bbox=dict(fc="none"))

text(0.95, 0.7, "Mag\nTTT$^{A^A}$\n123", size=18,
plt.text(0.95, 0.7, "Mag\nTTT$^{A^A}$\n123", size=18,
va="baseline", ha="right", multialignment="left",
bbox=dict(fc="none"))

xticks([0.2, 0.4, 0.6, 0.8, 1.],
plt.xticks([0.2, 0.4, 0.6, 0.8, 1.],
["Jan\n2009", "Feb\n2009", "Mar\n2009", "Apr\n2009", "May\n2009"])

axhline(0.7)
title("test line spacing for multiline text")
plt.axhline(0.7)
plt.title("test line spacing for multiline text")

subplots_adjust(bottom=0.25, top=0.8)
draw()
show()
plt.subplots_adjust(bottom=0.25, top=0.8)
plt.draw()
plt.show()