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')
https://raw.githubusercontent.com/OnionNinja/justplot/master/example/blueprint-1.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.
https://raw.githubusercontent.com/OnionNinja/justplot/master/example/blueprint-2.png

很好。现在假装你很喜欢这个情节 你未来的计划都是这样的。比如风的那个。 让我们这样做吧。

windy=blueprint.copy()windy(title={"label":"Wind","fontsize":19})windy.add_contour(xlat,xlon,wind,label="Wind")windy.save("windy.png","png")
https://raw.githubusercontent.com/OnionNinja/justplot/master/example/windy.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")
https://raw.githubusercontent.com/OnionNinja/justplot/master/example/both.png

您可以在example中找到示例代码和数据 文件夹。

如何改进模块(也称为ourtodo list)

  • []从Y轴保存设置
  • []添加basemap支持
  • []重组
  • []从预配置或使用的图形/轴写入导入功能
  • [X]write readme.md

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java JPA。Eclipselink没有为mySQL提供密码,但它应该提供   我的Servlet和@FormDataParam存在java问题   java将什么作为上下文参数传递到文件I/O方法中?   如果两个值相同,java无法找到其中一个单选按钮   java在变量和方法名中使用下划线   JavaSpringMVC单线程安全?   klazz类的java Arraylist(反射Api)   java如何在数字字符串中查找最频繁的数字?   JavaAPI设计:使数据更易于阅读与强制更多API调用   JavaHadoopMapReduceforGoogleWebGraph   java无法启动gauge API:Runner意外退出   java如何在bluemix上使用ibm工作负载调度器?   拉取一年中某一周特定日期的所有日期   java为什么是我的角节点。js应用程序将图像上传到S3� 邮递员正确上传时的符号?   在不使用任何第三方jar的情况下将文件从本地传输到linux系统(java代码)   java将现有文件夹复制到Eclipse工作区中新创建的项目中   Java中的regex RegExp帮助   当使用“系统”外观时,Java组合框setSelectedItem会出现故障   JavaASM:在类的方法中获取局部变量名和值