matplotlib周围的薄包装,用于保存图形和轴设置。
justplot的Python项目详细描述
matplotlib周围的一个薄包装,用于保存图形和轴 打印重用设置。
如何安装模块
pip使用--pre作为选项,因为这仍然是一个alpha构建。
python3.4 -m pip install justplot --pre
–或–
git clone https://github.com/OnionNinja/justplot cd justplot python3.4 setup.py install
如何使用模块[删除线:(按预期)]
tl;dr
fromjustplotimportjustplotasjpimportnumpylat=np.asarray([-90,-60,-30,0,30,60,90])lon=np.asarray([-180,-150,-120,-90,-60,-30,0,30,60,90,120,150,180])lat,lon=np.meshgrid(lat,lon)temp=np.random.randint(10,35,(13,7))wind=np.random.randint(100,300,(13,7))awesome=jp.JustPlot(title="Where is it hot?",xlabel="Latitude",ylabel="Longitude",# add more options here)awesome.add_contourf(lat,lon,temp,ylabel="Temperature (K)",colorbar=True)awesome.save("Sun.pdf","pdf")windy=awesome.copy()windy(title="A little bit windy don't ya think?")windy.add_contour(lat,lon,wind,ylabel="Wind")windy.save("Wind.pdf","pdf")
使用量
假设我们有一些数据要绘制(惊喜!).作为一个例子 将使用来自 ucar。
首先我们得加载数据。
importxarrayimportnumpyasnpdata=xarray.open_dataset('sresa1b_ncar_ccsm3-example.nc',decode_times=False)#pretty cryptic, I knowlat=data.lat.datalon=data.lon.datatemp=data.tas.data[0,:,:]wind=data.ua.data[0,4,:,:]xlat,xlon=np.meshgrid(lon,lat)
让我们先建立图形和轴设置。
fromjustplotimportjustplotasjpblueprint=jp.JustPlot(title="Where is it hot?",ylabel="Latitude",xlabel="Longitude",# add more options here)
现在我们可以添加实际的情节。
blueprint.add_contourf(xlat,xlon,temp,label="Temperature")blueprint.save('blueprint-1.png','png')
标题奇怪,太小了。另外,两个轴可以使用 再来点滴答声。所以让我们改变一下。
frommatplotlib.tickerimportAutoMinorLocatorblueprint(title={"label":"World Temperature","fontsize":19},xticks=np.arange(0,361,30),yticks=np.arange(-90,91,30),xminor=AutoMinorLocator(3),yminor=AutoMinorLocator(3),)blueprint.save("blueprint-2.png",'png')Basemapsupportwillbeaddedfurtherdowntheroad.Itison[STRIKEOUT:my]**our**todolist.Youcanquotemeonthat.
很好。现在假装你很喜欢这个情节 你未来的计划都是这样的。比如风的那个。 让我们这样做吧。
windy=blueprint.copy()windy(title={"label":"Wind","fontsize":19})windy.add_contour(xlat,xlon,wind,label="Wind")windy.save("windy.png","png")
让我们把这些放在一起。
both=windy.copy()both(title={"label":"World Temperature + Wind","fontsize":19})both.add_contourf(xlat,xlon,temp,label="Temperature")both.add_contour(xlat,xlon,wind,label="Wind",colors=('k'))blueprint.save("both.png","png")
您可以在example中找到示例代码和数据 文件夹。
如何改进模块(也称为ourtodo list)
- []从Y轴保存设置
- []添加basemap支持
- []重组
- []从预配置或使用的图形/轴写入导入功能
- [X]write readme.md