matplotlib 更改mplstereonet中的网格线间隔

wztqucjr  于 2023-03-03  发布在  其他
关注(0)|答案(1)|浏览(173)

每次我使用网格绘制立体图时,网格线的间隔是30度(如下所示)。有没有办法将网格线设置为10度?我使用mplstereonet
过去是每10度一次,如github页面https://github.com/joferkington/mplstereonet中的示例所示

我的MWE:

import pandas as pd
import mplstereonet as mpl

strike = [120,145,150]
dip = [30,44,72]

f, ax = mpl.subplots()
ax.pole(strike, dip)
ax.grid()
ax._polar.set_position(ax.get_position())
e4eetjau

e4eetjau1#

根据ax.xticksax.yticks设置网格线。注意,两个轴的尺寸均以弧度表示。
下面是一个选项(添加numpy依赖关系)

import pandas as pd
import mplstereonet as mpl
import numpy as np

strike = [120,145,150]
dip = [30,44,72]

f, ax = mpl.subplots()
ax.pole(strike, dip)
ax.grid(ls=":")  # Similar style as the example provided 

ymin, ymax = ax.get_ylim()
xmin, xmax = ax.get_xlim()

# Create x and y ticks every 10°
y_ticks = np.arange(ymin, ymax, np.deg2rad(10))
x_ticks = np.arange(ymin, ymax, np.deg2rad(10))

ax.set_xticks(x_ticks)
ax.set_yticks(y_ticks)

相关问题