8000 Default alignment of bar is center -> fix examples. · matplotlib/matplotlib@486c489 · GitHub
[go: up one dir, main page]

Skip to content

Commit 486c489

Browse files
committed
Default alignment of bar is center -> fix examples.
1 parent b6c476b commit 486c489

File tree

11 files changed

+12
-14
lines changed

11 files changed

+12
-14
lines changed

examples/api/barchart_demo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
# add some text for labels, title and axes ticks
2626
ax.set_ylabel('Scores')
2727
ax.set_title('Scores by group and gender')
28-
ax.set_xticks(ind + width)
28+
ax.set_xticks(ind + width / 2)
2929
ax.set_xticklabels(('G1', 'G2', 'G3', 'G4', 'G5'))
3030

3131
ax.legend((rects1[0], rects2[0]), ('Men', 'Women'))

examples/axes_grid/demo_floating_axes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def setup_axes1(fig, rect):
2727
tr = Affine2D().scale(2, 1).rotate_deg(30)
2828

2929
grid_helper = floating_axes.GridHelperCurveLinear(
30-
tr, extremes=(0, 4, 0, 4))
30+
tr, extremes=(-0.5, 3.5, 0, 4))
3131

3232
ax1 = floating_axes.FloatingSubplot(fig, rect, grid_helper=grid_helper)
3333
fig.add_subplot(ax1)

examples/pylab_examples/bar_stacked.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
plt.ylabel('Scores')
1919
plt.title('Scores by group and gender')
20-
plt.xticks(ind + width/2., ('G1', 'G2', 'G3', 'G4', 'G5'))
20+
plt.xticks(ind, ('G1', 'G2', 'G3', 'G4', 'G5'))
2121
plt.yticks(np.arange(0, 81, 10))
2222
plt.legend((p1[0], p2[0]), ('Men', 'Women'))
2323

examples/pylab_examples/barchart_demo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
plt.xlabel('Group')
3939
plt.ylabel('Scores')
4040
plt.title('Scores by group and gender')
41-
plt.xticks(index + bar_width, ('A', 'B', 'C', 'D', 'E'))
41+
plt.xticks(index + bar_width / 2, ('A', 'B', 'C', 'D', 'E'))
4242
plt.legend()
4343

4444
plt.tight_layout()

examples/pylab_examples/barchart_demo2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def plot_student_results(student, scores, cohort_size):
6969
fig.subplots_adjust(left=0.115, right=0.88)
7070
fig.canvas.set_window_title('Eldorado K-8 Fitness Chart')
7171

72-
pos = np.arange(len(testNames)) + 0.5 # Center bars on the Y-axis ticks
72+
pos = np.arange(len(testNames))
7373

7474
rects = ax1.barh(pos, [scores[k].percentile for k in testNames],
7575
align='center',

examples/pylab_examples/custom_ticker1.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@ def millions(x, pos):
2525
fig, ax = plt.subplots()
2626
ax.yaxis.set_major_formatter(formatter)
2727
plt.bar(x, money)
28-
plt.xticks(x + 0.5, ('Bill', 'Fred', 'Mary', 'Sue'))
28+
plt.xticks(x, ('Bill', 'Fred', 'Mary', 'Sue'))
2929
plt.show()

examples/pylab_examples/demo_agg_filter.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,6 @@ def drop_shadow_patches(ax):
283283
ax.add_artist(shadow)
284284
shadow.set_zorder(rects1[0].get_zorder() - 0.1)
285285

286 6D40 -
ax.set_xlim(ind[0] - 0.5, ind[-1] + 1.5)
287286
ax.set_ylim(0, 40)
288287

289288
ax.xaxis.set_visible(False)

examples/pylab_examples/log_bar.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
for i in range(len(data[0])):
1717
y = [d[i] for d in data]
1818
b = plt.bar(x + i * dimw, y, dimw, bottom=0.001)
19-
plt.xticks(x + w / 2)
19+
20+
plt.xticks(x + dimw / 2, map(str, x))
2021
plt.ylim((0.001, 1000))
2122

2223
plt.show()

examples/pylab_examples/system_monitor.py

Original file line numberDiff line numberDiff line change
@@ -29,14 +29,12 @@ def get_stats(t):
2929

3030

3131
pm, pc, pn = plt.bar(ind, get_stats(0))
32-
centers = ind + 0.5*pm.get_width()
3332
pm.set_facecolor('r')
3433
pc.set_facecolor('g')
3534
pn.set_facecolor('b')
36-
ax.set_xlim([0.5, 4])
37-
ax.set_xticks(centers)
38-
ax.set_ylim([0, 100])
35+
ax.set_xticks(ind)
3936
ax.set_xticklabels(['Memory', 'CPU', 'Bandwidth'])
37+
ax.set_ylim([0, 100])
4038
ax.set_ylabel('Percent usage')
4139
ax.set_title('System Monitor')
4240

Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
p2 = ax.bar(ind + width, womenMeans, width, color='y', bottom=0*cm, yerr=womenStd)
2020

2121
ax.set_title('Scores by group and gender')
22-
ax.set_xticks(ind + width)
22+
ax.set_xticks(ind + width / 2)
2323
ax.set_xticklabels(('G1', 'G2', 'G3', 'G4', 'G5'))
2424

2525
ax.legend((p1[0], p2[0]), ('Men', 'Women'))
Original file line numberDiff line numberDiff line change
@@ -1922,7 +1922,7 @@ def bar(self, left, height, width=0.8, bottom=None, **kwargs):
19221922
dictionary of kwargs to be passed to errorbar method. *ecolor* and
19231923
*capsize* may be specified here rather than as independent kwargs.
19241924
1925-
align : {'edge', 'center'}, optional
1925+
align : {'center', 'edge'}, optional
19261926
If 'edge', aligns bars by their left edges (for vertical bars) and
19271927
by their bottom edges (for horizontal bars). If 'center', interpret
19281928
the `left` argument as the coordinates of the centers of the bars.