小编Sey*_*avi的帖子

如何控制 xarray 中面网格行和/或列的顺序?

我正在尝试更改用于在 xarray 中制作构面网格的变量的顺序。例如,我将[a,b,c,d ] 作为列名称。我想将其重新排序为[c,d,a,b]。不幸的是,与seaborn不同,我无法在 xarray 绘图函数中找到 col_order 或 row_order 等参数(

\n
\n

https://xarray.pydata.org/en/stable/ generated/xarray.plot.FacetGrid.html

\n
\n

更新: \n为了帮助自己更好地解释我需要什么,我从 xarray 的用户指南中获取了下面的示例:\n在下面的示例中,我需要更改月份的位置。我的意思是,例如,我想将第 7 个月作为第一列,将第 2 个月作为第 5 列,依此类推。在此输入图像描述

\n
import matplotlib as mpl\nimport matplotlib.pyplot as plt\nimport numpy as np\nimport xarray as xr\nds = xr.tutorial.open_dataset("air_temperature.nc").rename({"air": "Tair"})\n\n# we will add a gradient field with appropriate attributes\nds["dTdx"] = ds.Tair.differentiate("lon") / 110e3 / np.cos(ds.lat * np.pi / 180)\nds["dTdy"] = ds.Tair.differentiate("lat") / 105e3\nds.dTdx.attrs = {"long_name": "$\xe2\x88\x82T/\xe2\x88\x82x$", "units": "\xc2\xb0C/m"}\nds.dTdy.attrs = {"long_name": "$\xe2\x88\x82T/\xe2\x88\x82y$", …
Run Code Online (Sandbox Code Playgroud)

python matplotlib seaborn python-xarray

1
推荐指数
1
解决办法
420
查看次数

如何在pycharm中制作部分

我刚刚从R转到Python。在R中,您可以使用

#new section####

to have the 'new section' as title in the script section list. Then, you could easily find that block of script by hitting this title within "Jump to menu" (please see figure). In this figure, the title is "reading data before 2013". 在此处输入图片说明 I have tried to find my answer here https://confluence.jetbrains.com/display/PYH/Code+folding and here https://www.jetbrains.com/help/pycharm/code-folding.html But I am lost in terms folding, class and .... Can you please let me know a simple way to mimic this option …

python pycharm

0
推荐指数
2
解决办法
85
查看次数

标签 统计

python ×2

matplotlib ×1

pycharm ×1

python-xarray ×1

seaborn ×1