8000 Merge pull request #3384 from cimarronm/test_marker_styles · matplotlib/matplotlib@561462f · GitHub
[go: up one dir, main page]

Skip to content

Commit 561462f

Browse files
committed
Merge pull request #3384 from cimarronm/test_marker_styles
TST : Test marker styles
2 parents 30891be + 45cfb2d commit 561462f

File tree

2 files changed

+53
-39
lines changed

2 files changed

+53
-39
lines changed
Loading

lib/matplotlib/tests/test_axes.py

Lines changed: 53 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -532,14 +532,14 @@ def test_nonfinite_limits():
532532
@image_comparison(baseline_images=['imshow'],
533533
remove_text=True)
534534
def test_imshow():
535-
#Create a NxN image
535+
# Create a NxN image
536536
N = 100
537537
(x, y) = np.indices((N, N))
538538
x -= N//2
539539
y -= N//2
540540
r = np.sqrt(x**2+y**2-x*y)
541541

542-
#Create a contour plot at N/4 and extract both the clip path and transform
542+
# Create a contour plot at N/4 and extract both the clip path and transform
543543
fig = plt.figure()
544544
ax = fig.add_subplot(111)
545545

@@ -550,14 +550,14 @@ def test_imshow():
550550
def test_imshow_clip():
551551
# As originally reported by Gellule Xg <gellule.xg@free.fr>
552552

553-
#Create a NxN image
553+
# Create a NxN image
554554
N = 100
555555
(x, y) = np.indices((N, N))
556556
x -= N//2
557557
y -= N//2
558558
r = np.sqrt(x**2+y**2-x*y)
559559

560-
#Create a contour plot at N/4 and extract both the clip path and transform
560+
# Create a contour plot at N/4 and extract both the clip path and transform
561561
fig = plt.figure()
562562
ax = fig.add_subplot(111)
563563

@@ -569,7 +569,7 @@ def test_imshow_clip():
569569
from matplotlib.transforms import TransformedPath
570570
clip_path = TransformedPath(clipPath, clipTransform)
571571

572-
#Plot the image clipped by the contour
572+
# Plot the image clipped by the contour
573573
ax.imshow(r, clip_path=clip_path)
574574

575575

@@ -851,12 +851,12 @@ def test_markevery_line():
851851
remove_text=True)
852852
def test_markevery_linear_scales():
853853
cases = [None,
854-
8,
855-
(30, 8),
856-
[16, 24, 30], [0,-1],
857-
slice(100, 200, 3),
858-
0.1, 0.3, 1.5,
859-
(0.0, 0.1), (0.45, 0.1)]
854+
8,
855+
(30, 8),
856+
[16, 24, 30], [0, -1],
857+
slice(100, 200, 3),
858+
0.1, 0.3, 1.5,
859+
(0.0, 0.1), (0.45, 0.1)]
860860

861861
cols = 3
862862
gs = matplotlib.gridspec.GridSpec(len(cases) // cols + 1, cols)
@@ -872,16 +872,17 @@ def test_markevery_linear_scales():
872872
plt.title('markevery=%s' % str(case))
873873
plt.plot(x, y, 'o', ls='-', ms=4, markevery=case)
874874

875+
875876
@image_comparison(baseline_images=['markevery_linear_scales_zoomed'],
876877
remove_text=True)
877878
def test_markevery_linear_scales_zoomed():
878879
cases = [None,
879-
8,
880-
(30, 8),
881-
[16, 24, 30], [0,-1],
882-
slice(100, 200, 3),
883-
0.1, 0.3, 1.5,
884-
(0.0, 0.1), (0.45, 0.1)]
880+
8,
881+
(30, 8),
882+
[16, 24, 30], [0, -1],
883+
slice(100, 200, 3),
884+
0.1, 0.3, 1.5,
885+
(0.0, 0.1), (0.45, 0.1)]
885886

886887
cols = 3
887888
gs = matplotlib.gridspec.GridSpec(len(cases) // cols + 1, cols)
@@ -904,12 +905,12 @@ def test_markevery_linear_scales_zoomed():
904905
remove_text=True)
905906
def test_markevery_log_scales():
906907
cases = [None,
907-
8,
908-
(30, 8),
909-
[16, 24, 30], [0,-1],
910-
slice(100, 200, 3),
911-
0.1, 0.3, 1.5,
912-
(0.0, 0.1), (0.45, 0.1)]
908+
8,
909+
(30, 8),
910+
[16, 24, 30], [0, -1],
911+
slice(100, 200, 3),
912+
0.1, 0.3, 1.5,
913+
(0.0, 0.1), (0.45, 0.1)]
913914

914915
cols = 3
915916
gs = matplotlib.gridspec.GridSpec(len(cases) // cols + 1, cols)
@@ -927,16 +928,17 @@ def test_markevery_log_scales():
927928
plt.yscale('log')
928929
plt.plot(x, y, 'o', ls='-', ms=4, markevery=case)
929930

931+
930932
@image_comparison(baseline_images=['markevery_polar'],
931933
remove_text=True)
932934
def test_markevery_polar():
933935
cases = [None,
934-
8,
935-
(30, 8),
936-
[16, 24, 30], [0,-1],
937-
slice(100, 200, 3),
938-
0.1, 0.3, 1.5,
939-
(0.0, 0.1), (0.45, 0.1)]
936+
8,
937+
(30, 8),
938+
[16, 24, 30], [0, -1],
939+
slice(100, 200, 3),
940+
0.1, 0.3, 1.5,
941+
(0.0, 0.1), (0.45, 0.1)]
940942

941943
cols = 3
942944
gs = matplotlib.gridspec.GridSpec(len(cases) // cols + 1, cols)
@@ -947,7 +949,7 @@ def test_markevery_polar():
947949
for i, case in enumerate(cases):
948950
row = (i // cols)
949951
col = i % cols
950-
plt.subplot(gs[row, col], polar = True)
952+
plt.subplot(gs[row, col], polar=True)
951953
plt.title('markevery=%s' % str(case))
952954
plt.plot(theta, r, 'o', ls='-', ms=4, markevery=case)
953955

@@ -988,7 +990,6 @@ def test_hist_steplog():
988990
ax = plt.subplot(4, 1, 2)
989991
plt.hist(data_pos, 100, histtype='stepfilled', log=True)
990992

991-
992993
ax = plt.subplot(4, 1, 3)
993994
plt.hist(data, 100, weights=weights, histtype='stepfilled', log=True)
994995

@@ -1040,7 +1041,7 @@ def test_contour_colorbar():
10401041
@image_comparison(baseline_images=['hist2d'])
10411042
def test_hist2d():
10421043
np.random.seed(0)
1043-
#make it not symetric in case we switch x and y axis
1044+
# make it not symetric in case we switch x and y axis
10441045
x = np.random.randn(100)*2+5
10451046
y = np.random.randn(100)-2
10461047
fig = plt.figure()
@@ -1051,8 +1052,8 @@ def test_hist2d():
10511052
@image_comparison(baseline_images=['hist2d_transpose'])
10521053
def test_hist2d_transpose():
10531054
np.random.seed(0)
1054-
#make sure the the output from np.histogram is transposed before
1055-
#passing to pcolorfast
1055+
# make sure the the output from np.histogram is transposed before
1056+
# passing to pcolorfast
10561057
x = np.array([5]*100)
10571058
y = np.random.randn(100)-2
10581059
fig = plt.figure()
@@ -1601,6 +1602,7 @@ def test_boxplot_bad_medians_1():
16011602
fig, ax = plt.subplots()
16021603
assert_raises(ValueError, ax.boxplot, x, usermedians=[1, 2])
16031604

1605+
16041606
@cleanup
16051607
def test_boxplot_bad_medians_2():
16061608
x = np.linspace(-7, 7, 140)
@@ -1808,7 +1810,7 @@ def test_manage_xticks():
18081810
np.random.seed(0)
18091811
y1 = np.random.normal(10, 3, 20)
18101812
y2 = np.random.normal(3, 1, 20)
1811-
ax.boxplot([y1, y2], positions = [1,2],
1813+
ax.boxplot([y1, y2], positions=[1, 2],
18121814
manage_xticks=False)
18131815
new_xlim = ax.get_xlim()
18141816
assert_array_equal(old_xlim, new_xlim)
@@ -2192,6 +2194,16 @@ def test_empty_eventplot():
21922194
plt.draw()
21932195

21942196

2197+
@image_comparison(baseline_images=['marker_styles'], extensions=['png'], remove_text=True)
2198+
def test_marker_styles():
2199+
fig = plt.figure()
2200+
ax = fig.add_subplot(111)
2201+
for y, marker in enumerate(sorted(matplotlib.markers.MarkerStyle.markers.keys(),
2202+
key=lambda x: str(type(x))+str(x))):
2203+
ax.plot((y % 2)*5 + np.arange(10)*10, np.ones(10)*10*y, linestyle='', marker=marker,
2204+
markersize=10+y/5, label=marker)
2205+
2206+
21952207
@image_comparison(baseline_images=['vertex_markers'], extensions=['png'],
21962208
remove_text=True)
21972209
def test_vertex_markers():
@@ -3251,7 +3263,7 @@ def test_vline_limit():
32513263

32523264
@cleanup
32533265
def test_empty_shared_subplots():
3254-
#empty plots with shared axes inherit limits from populated plots
3266+
# empty plots with shared axes inherit limits from populated plots
32553267
fig, axes = plt.subplots(nrows=1, ncols=2, sharex=True, sharey=True)
32563268
axes[0].plot([1, 2, 3], [2, 4, 6])
32573269
x0, x1 = axes[1].get_xlim()
@@ -3305,7 +3317,7 @@ def test_pie_linewidth_0():
33053317
labels = 'Frogs', 'Hogs', 'Dogs', 'Logs'
33063318
sizes = [15, 30, 45, 10]
33073319
colors = ['yellowgreen', 'gold', 'lightskyblue', 'lightcoral']
3308-
explode = (0, 0.1, 0, 0) # only "explode" the 2nd slice (i.e. 'Hogs')
3320+
explode = (0, 0.1, 0, 0) # only "explode" the 2nd slice (i.e. 'Hogs')
33093321

33103322
plt.pie(sizes, explode=explode, labels=labels, colors=colors,
33113323
autopct='%1.1f%%', shadow=True, startangle=90,
@@ -3320,7 +3332,7 @@ def test_pie_linewidth_2():
33203332
labels = 'Frogs', 'Hogs', 'Dogs', 'Logs'
33213333
sizes = [15, 30, 45, 10]
33223334
colors = ['yellowgreen', 'gold', 'lightskyblue', 'lightcoral']
3323-
explode = (0, 0.1, 0, 0) # only "explode" the 2nd slice (i.e. 'Hogs')
3335+
explode = (0, 0.1, 0, 0) # only "explode" the 2nd slice (i.e. 'Hogs')
33243336

33253337
plt.pie(sizes, explode=explode, labels=labels, colors=colors,
33263338
autopct='%1.1f%%', shadow=True, startangle=90,
@@ -3335,14 +3347,15 @@ def test_pie_ccw_true():
33353347
labels = 'Frogs', 'Hogs', 'Dogs', 'Logs'
33363348
sizes = [15, 30, 45, 10]
33373349
colors = ['yellowgreen', 'gold', 'lightskyblue', 'lightcoral']
3338-
explode = (0, 0.1, 0, 0) # only "explode" the 2nd slice (i.e. 'Hogs')
3350+
explode = (0, 0.1, 0, 0) # only "explode" the 2nd slice (i.e. 'Hogs')
33393351

33403352
plt.pie(sizes, explode=explode, labels=labels, colors=colors,
33413353
autopct='%1.1f%%', shadow=True, startangle=90,
33423354
counterclock=True)
33433355
# Set aspect ratio to be equal so that pie is drawn as a circle.
33443356
plt.axis('equal')
33453357

3358+
33463359
@cleanup
33473360
def test_margins():
33483361
# test all ways margins can be called
@@ -3363,6 +3376,7 @@ def test_margins():
33633376
ax3.margins(x=1, y=0.5)
33643377
assert_equal(ax3.margins(), (1, 0.5))
33653378

3379+
33663380
@cleanup
33673381
def test_pathological_hexbin():
33683382
# issue #2863

0 commit comments

Comments
 (0)
0