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如何在安卓中更改SeekBar颜色?(以编程方式)   java在本地测试SpringOpenShift应用程序   java为什么局部变量仍然显示警告,尽管方法中使用了值?   未解析java Spring启动验证消息   java MultiSelectListPreference是否获取检查值?   xml签名中的java引用验证   eclipse JWNL(Java WordNet库)和WordNet   java Firebase addValueEventListener是否异步工作?   单选按钮的java@FindBy注释   通过JAVA Web服务调用时,安卓 ClassNotFound异常?   java Try catch不起作用(总是执行catch代码)   为什么Eclipse在尝试导入现有java项目或创建新项目时关闭时没有任何错误消息?   java Genesys Composer应用程序与Eclipse RCP应用程序有何不同   java替换方法无法正常工作   使用JavaFX8构建java MOJO   Spark使用Java没有可用的实时SolrServer来处理此请求   Java Optaplanner在不同的机器上进行不同的计算   在类之间导入java变量   在或多个运营商SAP Java中   java Hibernate保存SQL异常