X Tutup
Skip to content
Merged
Show file tree
Hide file tree
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
12 changes: 8 additions & 4 deletions examples/lines_bars_and_markers/barh_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,20 @@


plt.rcdefaults()
fig, ax = plt.subplots()

# Example data
people = ('Tom', 'Dick', 'Harry', 'Slim', 'Jim')
y_pos = np.arange(len(people))
performance = 3 + 10 * np.random.rand(len(people))
error = np.random.rand(len(people))

plt.barh(y_pos, performance, xerr=error, align='center')
plt.yticks(y_pos, people)
plt.xlabel('Performance')
plt.title('How fast do you want to go today?')
ax.barh(y_pos, performance, xerr=error, align='center',
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we do not want to backport this to v2.x, this can use @story645 's categorical work. ax.barh(people, performance) should 'just work'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am in favor of merging now and backporting, and create another PR for the categorical bar plot.

color='green', ecolor='black')
ax.set_yticks(y_pos)
ax.set_yticklabels(people)
ax.invert_yaxis() # labels read top-to-bottom
ax.set_xlabel('Performance')
ax.set_title('How fast do you want to go today?')

plt.show()
6 changes: 4 additions & 2 deletions examples/lines_bars_and_markers/fill_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
x = np.linspace(0, 1, 500)
y = np.sin(4 * np.pi * x) * np.exp(-5 * x)

plt.fill(x, y)
plt.grid(True)
fig, ax = plt.subplots()

ax.fill(x, y, zorder=10)
ax.grid(True, zorder=5)
plt.show()
4 changes: 3 additions & 1 deletion examples/lines_bars_and_markers/fill_demo_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@
x = np.linspace(0, 2 * np.pi, 500)
y1 = np.sin(x)
y2 = np.sin(3 * x)
plt.fill(x, y1, 'b', x, y2, 'r', alpha=0.3)

fig, ax = plt.subplots()
ax.fill(x, y1, 'b', x, y2, 'r', alpha=0.3)
plt.show()
12 changes: 9 additions & 3 deletions examples/lines_bars_and_markers/line_demo_dash_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,15 @@


x = np.linspace(0, 10, 500)
line, = plt.plot(x, np.sin(x), '--', linewidth=2)

dashes = [10, 5, 100, 5] # 10 points on, 5 off, 100 on, 5 off
line.set_dashes(dashes)

fig, ax = plt.subplots()
line1, = ax.plot(x, np.sin(x), '--', linewidth=2,
label='Dashes set retroactively')
line1.set_dashes(dashes)

line2, = ax.plot(x, -1 * np.sin(x), dashes=[30, 5, 10, 5],
label='Dashes set proactively')

ax.legend(loc='lower right')
plt.show()
2 changes: 1 addition & 1 deletion examples/lines_bars_and_markers/line_styles_reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def nice_repr(text):


# Plot all line styles.
f, ax = plt.subplots()
fig, ax = plt.subplots()

linestyles = ['-', '--', '-.', ':']
for y, linestyle in enumerate(linestyles):
Expand Down
9 changes: 5 additions & 4 deletions examples/lines_bars_and_markers/scatter_with_legend.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@
from numpy.random import rand


fig, ax = plt.subplots()
for color in ['red', 'green', 'blue']:
n = 750
x, y = rand(2, n)
scale = 200.0 * rand(n)
plt.scatter(x, y, c=color, s=scale, label=color,
alpha=0.3, edgecolors='none')
ax.scatter(x, y, c=color, s=scale, label=color,
alpha=0.3, edgecolors='none')

plt.legend()
plt.grid(True)
ax.legend()
ax.grid(True)

plt.show()
X Tutup