Python matplotlib.collections.PathCollection() Examples
The following are 28
code examples of matplotlib.collections.PathCollection().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
matplotlib.collections
, or try the search function
.
Example #1
Source File: CV_diode_plots.py From DIY_particle_detector with BSD 2-Clause "Simplified" License | 6 votes |
def plotCV(df,columns,colors): ### plot C-V curve fig = plt.figure() plot = fig.add_subplot(111) i = 0 for column in df[columns]: plot.errorbar(df.VBias,df[column],yerr=df[column]*df[column+'_err'].values,fmt='s',markeredgewidth=1,markersize=3,label=column,markerfacecolor='none',color='none', markeredgecolor=colors[i]) i +=1 txt = r"\n(errors are smaller than marker symbols)" plot.set_ylabel('Capacitance [pF]', fontsize=14) plot.set_xlabel('Reverse bias voltage [|V|]', fontsize=14)#+ txt ) plot.set_yscale('log') plot.set_xscale('log') def update2(handle, orig): handle.update_from(orig) handle.set_sizes([100]) plot.legend(handler_map={PathCollection : HandlerPathCollection(update_func=update2)},fontsize=10,scatterpoints=5) plot.grid(which='minor',linewidth=0.5) plot.grid(which='major',linewidth=1.0) plot.set_xticklabels(list(map(str, [0.001,0.01,0.1,1,10]))) # WARNING: adapt in case of other changes plot.set_yticklabels(list(map(str, [0.1,1,10,100,1000]))) # WARNING: adapt in case of other changes fig.tight_layout(pad=0.2)
Example #2
Source File: CV_diode_plots.py From DIY_particle_detector with BSD 2-Clause "Simplified" License | 5 votes |
def plotNeff(df, columns,colors): fig = plt.figure() plot = fig.add_subplot(111) i =0 for column in df[columns]: print(column) # RAW C data to Neff d_raw = depth(df[column].values)*10000 # in um neff_raw = Neff(df[column+'_cc'], df.VBias)#df.VBias[1]-df.VBias[0] )#df.VBias.values) cc_err_max = 1.0/((df[column]*(1+df[column+'_err'].values)) * (df[column]*(1+df[column+'_err'].values))) cc_err_min = 1.0/((df[column]*(1-df[column+'_err'].values)) * (df[column]*(1-df[column+'_err'].values))) neff_err_max = Neff(cc_err_max, df.VBias) neff_err_min = Neff(cc_err_min, df.VBias) plot.plot(d_raw,neff_err_max, linewidth=0.1,color=colors[i]) plot.plot(d_raw,neff_err_min, linewidth=0.1,color=colors[i]) plot.scatter(x=d_raw, y=neff_raw,s=1.5,marker='d', label=column, color=colors[i]) i+=1 txt = r"\n(errors are smaller than marker symbols)" plot.set_xlabel('Depletion layer depth ['+u'\u03bc'+'m]') #+ txt ) plot.set_ylabel('Neff [cm$^{-3}$]') plot.set_yscale('log') plot.set_xscale('log') def update1(handle, orig): handle.update_from(orig) handle.set_sizes([30]) plot.legend(handler_map={PathCollection : HandlerPathCollection(update_func=update1)},fontsize=10,scatterpoints=1,loc=4) plot.set_xticklabels(list(map(str, [0.1,1,10,100]))) # WARNING: adapt in case of other changes fig.tight_layout(pad=0.2)
Example #3
Source File: test_artist.py From twitter-stock-recommendation with MIT License | 5 votes |
def test_clipping(): exterior = mpath.Path.unit_rectangle().deepcopy() exterior.vertices *= 4 exterior.vertices -= 2 interior = mpath.Path.unit_circle().deepcopy() interior.vertices = interior.vertices[::-1] clip_path = mpath.Path(vertices=np.concatenate([exterior.vertices, interior.vertices]), codes=np.concatenate([exterior.codes, interior.codes])) star = mpath.Path.unit_regular_star(6).deepcopy() star.vertices *= 2.6 ax1 = plt.subplot(121) col = mcollections.PathCollection([star], lw=5, edgecolor='blue', facecolor='red', alpha=0.7, hatch='*') col.set_clip_path(clip_path, ax1.transData) ax1.add_collection(col) ax2 = plt.subplot(122, sharex=ax1, sharey=ax1) patch = mpatches.PathPatch(star, lw=5, edgecolor='blue', facecolor='red', alpha=0.7, hatch='*') patch.set_clip_path(clip_path, ax2.transData) ax2.add_patch(patch) ax1.set_xlim([-3, 3]) ax1.set_ylim([-3, 3])
Example #4
Source File: test_collections.py From twitter-stock-recommendation with MIT License | 5 votes |
def test_joinstyle(): col = mcollections.PathCollection([], joinstyle='round') assert_equal(col.get_joinstyle(), 'round') col.set_joinstyle('miter') assert_equal(col.get_joinstyle(), 'miter')
Example #5
Source File: test_collections.py From twitter-stock-recommendation with MIT License | 5 votes |
def test_lslw_bcast(): col = mcollections.PathCollection([]) col.set_linestyles(['-', '-']) col.set_linewidths([1, 2, 3]) assert_equal(col.get_linestyles(), [(None, None)] * 6) assert_equal(col.get_linewidths(), [1, 2, 3] * 2) col.set_linestyles(['-', '-', '-']) assert_equal(col.get_linestyles(), [(None, None)] * 3) assert_equal(col.get_linewidths(), [1, 2, 3])
Example #6
Source File: test_collections.py From twitter-stock-recommendation with MIT License | 5 votes |
def test_null_collection_datalim(): col = mcollections.PathCollection([]) col_data_lim = col.get_datalim(mtransforms.IdentityTransform()) assert_array_equal(col_data_lim.get_points(), mtransforms.Bbox.null().get_points())
Example #7
Source File: test_patches.py From twitter-stock-recommendation with MIT License | 5 votes |
def test_patch_custom_linestyle(): #: A test to check that patches and collections accept custom dash #: patterns as linestyle and that they display correctly. star = mpath.Path.unit_regular_star(6) circle = mpath.Path.unit_circle() # concatenate the star with an internal cutout of the circle verts = np.concatenate([circle.vertices, star.vertices[::-1]]) codes = np.concatenate([circle.codes, star.codes]) cut_star1 = mpath.Path(verts, codes) cut_star2 = mpath.Path(verts + 1, codes) ax = plt.axes() patch = mpatches.PathPatch(cut_star1, linewidth=5, linestyle=(0.0, (5.0, 7.0, 10.0, 7.0)), facecolor=(1, 0, 0), edgecolor=(0, 0, 1)) ax.add_patch(patch) col = mcollections.PathCollection([cut_star2], linewidth=5, linestyles=[(0.0, (5.0, 7.0, 10.0, 7.0))], facecolor=(1, 0, 0), edgecolor=(0, 0, 1)) ax.add_collection(col) ax.set_xlim([-1, 2]) ax.set_ylim([-1, 2])
Example #8
Source File: test_patches.py From twitter-stock-recommendation with MIT License | 5 votes |
def test_patch_alpha_override(): #: Test checks that specifying an alpha attribute for a patch or #: collection will override any alpha component of the facecolor #: or edgecolor. star = mpath.Path.unit_regular_star(6) circle = mpath.Path.unit_circle() # concatenate the star with an internal cutout of the circle verts = np.concatenate([circle.vertices, star.vertices[::-1]]) codes = np.concatenate([circle.codes, star.codes]) cut_star1 = mpath.Path(verts, codes) cut_star2 = mpath.Path(verts + 1, codes) ax = plt.axes() patch = mpatches.PathPatch(cut_star1, linewidth=5, linestyle='dashdot', alpha=0.25, facecolor=(1, 0, 0, 0.5), edgecolor=(0, 0, 1, 0.75)) ax.add_patch(patch) col = mcollections.PathCollection([cut_star2], linewidth=5, linestyles='dashdot', alpha=0.25, facecolor=(1, 0, 0, 0.5), edgecolor=(0, 0, 1, 0.75)) ax.add_collection(col) ax.set_xlim([-1, 2]) ax.set_ylim([-1, 2])
Example #9
Source File: test_patches.py From twitter-stock-recommendation with MIT License | 5 votes |
def test_patch_alpha_coloring(): """ Test checks that the patch and collection are rendered with the specified alpha values in their facecolor and edgecolor. """ star = mpath.Path.unit_regular_star(6) circle = mpath.Path.unit_circle() # concatenate the star with an internal cutout of the circle verts = np.concatenate([circle.vertices, star.vertices[::-1]]) codes = np.concatenate([circle.codes, star.codes]) cut_star1 = mpath.Path(verts, codes) cut_star2 = mpath.Path(verts + 1, codes) ax = plt.axes() patch = mpatches.PathPatch(cut_star1, linewidth=5, linestyle='dashdot', facecolor=(1, 0, 0, 0.5), edgecolor=(0, 0, 1, 0.75)) ax.add_patch(patch) col = mcollections.PathCollection([cut_star2], linewidth=5, linestyles='dashdot', facecolor=(1, 0, 0, 0.5), edgecolor=(0, 0, 1, 0.75)) ax.add_collection(col) ax.set_xlim([-1, 2]) ax.set_ylim([-1, 2])
Example #10
Source File: test_artist.py From coffeegrindsize with MIT License | 5 votes |
def test_clipping(): exterior = mpath.Path.unit_rectangle().deepcopy() exterior.vertices *= 4 exterior.vertices -= 2 interior = mpath.Path.unit_circle().deepcopy() interior.vertices = interior.vertices[::-1] clip_path = mpath.Path(vertices=np.concatenate([exterior.vertices, interior.vertices]), codes=np.concatenate([exterior.codes, interior.codes])) star = mpath.Path.unit_regular_star(6).deepcopy() star.vertices *= 2.6 ax1 = plt.subplot(121) col = mcollections.PathCollection([star], lw=5, edgecolor='blue', facecolor='red', alpha=0.7, hatch='*') col.set_clip_path(clip_path, ax1.transData) ax1.add_collection(col) ax2 = plt.subplot(122, sharex=ax1, sharey=ax1) patch = mpatches.PathPatch(star, lw=5, edgecolor='blue', facecolor='red', alpha=0.7, hatch='*') patch.set_clip_path(clip_path, ax2.transData) ax2.add_patch(patch) ax1.set_xlim([-3, 3]) ax1.set_ylim([-3, 3])
Example #11
Source File: test_collections.py From coffeegrindsize with MIT License | 5 votes |
def test_joinstyle(): col = mcollections.PathCollection([], joinstyle='round') assert col.get_joinstyle() == 'round' col.set_joinstyle('miter') assert col.get_joinstyle() == 'miter'
Example #12
Source File: test_collections.py From coffeegrindsize with MIT License | 5 votes |
def test_capstyle(): col = mcollections.PathCollection([], capstyle='round') assert col.get_capstyle() == 'round' col.set_capstyle('butt') assert col.get_capstyle() == 'butt'
Example #13
Source File: test_collections.py From coffeegrindsize with MIT License | 5 votes |
def test_lslw_bcast(): col = mcollections.PathCollection([]) col.set_linestyles(['-', '-']) col.set_linewidths([1, 2, 3]) assert col.get_linestyles() == [(None, None)] * 6 assert col.get_linewidths() == [1, 2, 3] * 2 col.set_linestyles(['-', '-', '-']) assert col.get_linestyles() == [(None, None)] * 3 assert (col.get_linewidths() == [1, 2, 3]).all()
Example #14
Source File: test_collections.py From coffeegrindsize with MIT License | 5 votes |
def test_null_collection_datalim(): col = mcollections.PathCollection([]) col_data_lim = col.get_datalim(mtransforms.IdentityTransform()) assert_array_equal(col_data_lim.get_points(), mtransforms.Bbox.null().get_points())
Example #15
Source File: test_patches.py From neural-network-animation with MIT License | 5 votes |
def test_patch_alpha_coloring(): """ Test checks that the patch and collection are rendered with the specified alpha values in their facecolor and edgecolor. """ star = mpath.Path.unit_regular_star(6) circle = mpath.Path.unit_circle() # concatenate the star with an internal cutout of the circle verts = np.concatenate([circle.vertices, star.vertices[::-1]]) codes = np.concatenate([circle.codes, star.codes]) cut_star1 = mpath.Path(verts, codes) cut_star2 = mpath.Path(verts + 1, codes) ax = plt.axes() patch = mpatches.PathPatch(cut_star1, linewidth=5, linestyle='dashdot', facecolor=(1, 0, 0, 0.5), edgecolor=(0, 0, 1, 0.75)) ax.add_patch(patch) col = mcollections.PathCollection([cut_star2], linewidth=5, linestyles='dashdot', facecolor=(1, 0, 0, 0.5), edgecolor=(0, 0, 1, 0.75)) ax.add_collection(col) ax.set_xlim([-1, 2]) ax.set_ylim([-1, 2])
Example #16
Source File: test_collections.py From ImageFusion with MIT License | 5 votes |
def test_null_collection_datalim(): col = mcollections.PathCollection([]) col_data_lim = col.get_datalim(mtransforms.IdentityTransform()) assert_array_equal(col_data_lim.get_points(), mtransforms.Bbox.null().get_points())
Example #17
Source File: test_patches.py From ImageFusion with MIT License | 5 votes |
def test_patch_custom_linestyle(): #: A test to check that patches and collections accept custom dash #: patterns as linestyle and that they display correctly. star = mpath.Path.unit_regular_star(6) circle = mpath.Path.unit_circle() # concatenate the star with an internal cutout of the circle verts = np.concatenate([circle.vertices, star.vertices[::-1]]) codes = np.concatenate([circle.codes, star.codes]) cut_star1 = mpath.Path(verts, codes) cut_star2 = mpath.Path(verts + 1, codes) ax = plt.axes() patch = mpatches.PathPatch(cut_star1, linewidth=5, linestyle=(0.0, (5.0, 7.0, 10.0, 7.0)), facecolor=(1, 0, 0), edgecolor=(0, 0, 1)) ax.add_patch(patch) col = mcollections.PathCollection([cut_star2], linewidth=5, linestyles=[(0.0, (5.0, 7.0, 10.0, 7.0))], facecolor=(1, 0, 0), edgecolor=(0, 0, 1)) ax.add_collection(col) ax.set_xlim([-1, 2]) ax.set_ylim([-1, 2])
Example #18
Source File: test_patches.py From ImageFusion with MIT License | 5 votes |
def test_patch_alpha_override(): #: Test checks that specifying an alpha attribute for a patch or #: collection will override any alpha component of the facecolor #: or edgecolor. star = mpath.Path.unit_regular_star(6) circle = mpath.Path.unit_circle() # concatenate the star with an internal cutout of the circle verts = np.concatenate([circle.vertices, star.vertices[::-1]]) codes = np.concatenate([circle.codes, star.codes]) cut_star1 = mpath.Path(verts, codes) cut_star2 = mpath.Path(verts + 1, codes) ax = plt.axes() patch = mpatches.PathPatch(cut_star1, linewidth=5, linestyle='dashdot', alpha=0.25, facecolor=(1, 0, 0, 0.5), edgecolor=(0, 0, 1, 0.75)) ax.add_patch(patch) col = mcollections.PathCollection([cut_star2], linewidth=5, linestyles='dashdot', alpha=0.25, facecolor=(1, 0, 0, 0.5), edgecolor=(0, 0, 1, 0.75)) ax.add_collection(col) ax.set_xlim([-1, 2]) ax.set_ylim([-1, 2])
Example #19
Source File: test_patches.py From ImageFusion with MIT License | 5 votes |
def test_patch_alpha_coloring(): """ Test checks that the patch and collection are rendered with the specified alpha values in their facecolor and edgecolor. """ star = mpath.Path.unit_regular_star(6) circle = mpath.Path.unit_circle() # concatenate the star with an internal cutout of the circle verts = np.concatenate([circle.vertices, star.vertices[::-1]]) codes = np.concatenate([circle.codes, star.codes]) cut_star1 = mpath.Path(verts, codes) cut_star2 = mpath.Path(verts + 1, codes) ax = plt.axes() patch = mpatches.PathPatch(cut_star1, linewidth=5, linestyle='dashdot', facecolor=(1, 0, 0, 0.5), edgecolor=(0, 0, 1, 0.75)) ax.add_patch(patch) col = mcollections.PathCollection([cut_star2], linewidth=5, linestyles='dashdot', facecolor=(1, 0, 0, 0.5), edgecolor=(0, 0, 1, 0.75)) ax.add_collection(col) ax.set_xlim([-1, 2]) ax.set_ylim([-1, 2])
Example #20
Source File: test_artist.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_clipping(): exterior = mpath.Path.unit_rectangle().deepcopy() exterior.vertices *= 4 exterior.vertices -= 2 interior = mpath.Path.unit_circle().deepcopy() interior.vertices = interior.vertices[::-1] clip_path = mpath.Path(vertices=np.concatenate([exterior.vertices, interior.vertices]), codes=np.concatenate([exterior.codes, interior.codes])) star = mpath.Path.unit_regular_star(6).deepcopy() star.vertices *= 2.6 ax1 = plt.subplot(121) col = mcollections.PathCollection([star], lw=5, edgecolor='blue', facecolor='red', alpha=0.7, hatch='*') col.set_clip_path(clip_path, ax1.transData) ax1.add_collection(col) ax2 = plt.subplot(122, sharex=ax1, sharey=ax1) patch = mpatches.PathPatch(star, lw=5, edgecolor='blue', facecolor='red', alpha=0.7, hatch='*') patch.set_clip_path(clip_path, ax2.transData) ax2.add_patch(patch) ax1.set_xlim([-3, 3]) ax1.set_ylim([-3, 3])
Example #21
Source File: test_collections.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_joinstyle(): col = mcollections.PathCollection([], joinstyle='round') assert col.get_joinstyle() == 'round' col.set_joinstyle('miter') assert col.get_joinstyle() == 'miter'
Example #22
Source File: test_collections.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_capstyle(): col = mcollections.PathCollection([], capstyle='round') assert col.get_capstyle() == 'round' col.set_capstyle('butt') assert col.get_capstyle() == 'butt'
Example #23
Source File: test_collections.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_lslw_bcast(): col = mcollections.PathCollection([]) col.set_linestyles(['-', '-']) col.set_linewidths([1, 2, 3]) assert col.get_linestyles() == [(None, None)] * 6 assert col.get_linewidths() == [1, 2, 3] * 2 col.set_linestyles(['-', '-', '-']) assert col.get_linestyles() == [(None, None)] * 3 assert (col.get_linewidths() == [1, 2, 3]).all()
Example #24
Source File: test_collections.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_null_collection_datalim(): col = mcollections.PathCollection([]) col_data_lim = col.get_datalim(mtransforms.IdentityTransform()) assert_array_equal(col_data_lim.get_points(), mtransforms.Bbox.null().get_points())
Example #25
Source File: test_artist.py From neural-network-animation with MIT License | 5 votes |
def test_clipping(): exterior = mpath.Path.unit_rectangle().deepcopy() exterior.vertices *= 4 exterior.vertices -= 2 interior = mpath.Path.unit_circle().deepcopy() interior.vertices = interior.vertices[::-1] clip_path = mpath.Path(vertices=np.concatenate([exterior.vertices, interior.vertices]), codes=np.concatenate([exterior.codes, interior.codes])) star = mpath.Path.unit_regular_star(6).deepcopy() star.vertices *= 2.6 ax1 = plt.subplot(121) col = mcollections.PathCollection([star], lw=5, edgecolor='blue', facecolor='red', alpha=0.7, hatch='*') col.set_clip_path(clip_path, ax1.transData) ax1.add_collection(col) ax2 = plt.subplot(122, sharex=ax1, sharey=ax1) patch = mpatches.PathPatch(star, lw=5, edgecolor='blue', facecolor='red', alpha=0.7, hatch='*') patch.set_clip_path(clip_path, ax2.transData) ax2.add_patch(patch) ax1.set_xlim([-3, 3]) ax1.set_ylim([-3, 3])
Example #26
Source File: test_collections.py From neural-network-animation with MIT License | 5 votes |
def test_null_collection_datalim(): col = mcollections.PathCollection([]) col_data_lim = col.get_datalim(mtransforms.IdentityTransform()) assert_array_equal(col_data_lim.get_points(), mtransforms.Bbox.null().get_points())
Example #27
Source File: test_patches.py From neural-network-animation with MIT License | 5 votes |
def test_patch_custom_linestyle(): #: A test to check that patches and collections accept custom dash #: patterns as linestyle and that they display correctly. star = mpath.Path.unit_regular_star(6) circle = mpath.Path.unit_circle() # concatenate the star with an internal cutout of the circle verts = np.concatenate([circle.vertices, star.vertices[::-1]]) codes = np.concatenate([circle.codes, star.codes]) cut_star1 = mpath.Path(verts, codes) cut_star2 = mpath.Path(verts + 1, codes) ax = plt.axes() patch = mpatches.PathPatch(cut_star1, linewidth=5, linestyle=(0.0, (5.0, 7.0, 10.0, 7.0)), facecolor=(1, 0, 0), edgecolor=(0, 0, 1)) ax.add_patch(patch) col = mcollections.PathCollection([cut_star2], linewidth=5, linestyles=[(0.0, (5.0, 7.0, 10.0, 7.0))], facecolor=(1, 0, 0), edgecolor=(0, 0, 1)) ax.add_collection(col) ax.set_xlim([-1, 2]) ax.set_ylim([-1, 2])
Example #28
Source File: test_patches.py From neural-network-animation with MIT License | 5 votes |
def test_patch_alpha_override(): #: Test checks that specifying an alpha attribute for a patch or #: collection will override any alpha component of the facecolor #: or edgecolor. star = mpath.Path.unit_regular_star(6) circle = mpath.Path.unit_circle() # concatenate the star with an internal cutout of the circle verts = np.concatenate([circle.vertices, star.vertices[::-1]]) codes = np.concatenate([circle.codes, star.codes]) cut_star1 = mpath.Path(verts, codes) cut_star2 = mpath.Path(verts + 1, codes) ax = plt.axes() patch = mpatches.PathPatch(cut_star1, linewidth=5, linestyle='dashdot', alpha=0.25, facecolor=(1, 0, 0, 0.5), edgecolor=(0, 0, 1, 0.75)) ax.add_patch(patch) col = mcollections.PathCollection([cut_star2], linewidth=5, linestyles='dashdot', alpha=0.25, facecolor=(1, 0, 0, 0.5), edgecolor=(0, 0, 1, 0.75)) ax.add_collection(col) ax.set_xlim([-1, 2]) ax.set_ylim([-1, 2])