Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Graph is wrong when saved as .eps #14272

Open
@wolkchen-cirrus

Description

@wolkchen-cirrus

Bug report

Bug summary

Cross-hatching and shaded regions not being rendered when saving a figure as .eps (a format which most journals prefer). pdf and png work fine.

Code is as Follows, cannot show actual data since it is sensitive material at this stage

frommatplotlibimportpyplotaspltfrommatplotlibimportfont_managerasplt_fntfrommatplotlibimportrcParamsasmplParamsfrommatplotlibimportlinesfrommatplotlib.legendimportLegendimportnumpyasnpplt.style.use("ggplot")prop=plt_fnt.FontProperties(family=['serif'])mplParams["font.family"]=prop.get_name()mplParams['hatch.linewidth']=0.5mplParams['mathtext.default']="regular"mplParams['lines.antialiased']=FalsemplParams['patch.antialiased']=Falsedef_gen_dummy_data():out= {}foriinrange(5):key="key"+str(i)x=np.arange(0,5,0.5).reshape((-1,1))data1=np.random.normal(np.sin(x),0.5)data2=data1-0.2data3=data1+0.2data=np.hstack((x,data2,data3,data1))out[key]=datareturnoutdef_cm_to_inch(*tupl):inch=2.54ifisinstance(tupl[0],tuple):returntuple(k/inchforkintupl[0])else:returntuple(k/inchforkintupl)def_plot_avg_velocity(velocity_arr):aoa_lim=10v_mean=5fig=plt.figure()fig.set_size_inches(_cm_to_inch(12,8))ax=fig.add_subplot(111)title_string="Radial Velocity of Airflow During CFD Simulations"ax.set_title(title_string,fontsize="small")marker_style=dict(linestyle='-',marker='',markersize=5,fillstyle='none',color='C0')legend1_style=dict(marker='',color='C0',linestyle='-',fillstyle='none')fill_style=dict(alpha=0.5,edgecolor='C0',facecolor='C0')vel_err= {}forkeyinvelocity_arr:vel_err[key]=_get_err(velocity_arr[key])mean_handles= {}leg_names= []leg_handles= []i=0forkeyinvel_err:legend1_style['color']="C"+str(i)leg_handle=lines.Line2D([], [],**legend1_style)leg_handles.append(leg_handle)leg_str="Radius: %s m"%keyleg_names.append(str(leg_str))marker_style["color"]="C"+str(i)fill_style["edgecolor"]="C"+str(i)fill_style["facecolor"]="C"+str(i)mean_handles[key]=ax.plot(vel_err[key][:,0],vel_err[key][:,-1],**marker_style)ax.fill_between(vel_err[key][:,0],vel_err[key][:,1],vel_err[key][:,2],**fill_style)i+=1ax2=ax.twinx()ax_limits=ax.get_ylim()ax.set_ylim(ax_limits[0],ax_limits[1]+0.2)ax_limits=ax.get_ylim()ax2_limits=_vel_to_aoa(v_mean,ax_limits)ax2.set_ylim(ax2_limits[0],ax2_limits[1])ax2.grid(b=None)ax.autoscale(False)ax2.autoscale(False)ax2_xlim=ax2.get_xlim()ax2.fill([ax2_xlim[0],ax2_xlim[1],ax2_xlim[1],ax2_xlim[0]], [aoa_lim,aoa_lim,ax2_limits[1],ax2_limits[1]],fill=False,hatch='\\',edgecolor='0')ax2.plot([-10,10], [0,0],linestyle='-.',color=[0,0,0],linewidth=0.5)leg1=Legend(ax,leg_handles,leg_names,fontsize="small",frameon=False,loc=5,ncol=1)ax.add_artist(leg1)ax.set_xlabel("Distance Above Rotors (m)",fontsize="small")ax.set_ylabel("Radial Velocity ($ms^{-1}$)",fontsize="small")ax2.set_ylabel("Equivalent Airflow Angle of Attack ($^{\circ}$)",fontsize="small")plt.tight_layout()plt.show()returndef_get_err(vel_arr):err_arr=vel_arr[:,1:(-1-1)]avg_arr=vel_arr[:,-1]z_arr=vel_arr[:,0]rows,cols=err_arr.shapemin_arr=np.zeros([rows])max_arr=np.zeros([rows])vel_err_arr=np.zeros([rows,4])foriinrange(rows):min_arr[i]=np.min(err_arr[i, :])max_arr[i]=np.max(err_arr[i, :])vel_err_arr[:,0]=z_arrvel_err_arr[:,1]=min_arrvel_err_arr[:,2]=max_arrvel_err_arr[:,3]=avg_arrreturnvel_err_arrdef_vel_to_aoa(v_mean,v):ifisinstance(v,tuple):returntuple(np.arctan(i/v_mean)*180/np.piforiinv)else:returnnp.arctan(v/v_mean)dat=_gen_dummy_data()_plot_avg_velocity(dat)

Actual outcome

Unfortunately I am unable to share data from this graph. Dummy data instead:

test_fig

Expected outcome

The graph rendered with cross-hatching and shaded regions

Matplotlib version

  • Operating system: Windows 10 (also tried on scientific linux 7)
  • Matplotlib version: 2.2.4
  • Matplotlib backend (print(matplotlib.get_backend())):
  • Python version: 2.7
  • Jupyter version (if applicable): N/A
  • Other libraries: numpy

Installed matplotlib via pip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp