Julia PyPlot中的网格线

ADM*_*DMD 3 matplotlib julia

我在Julia中使用"PyPlot"包,我想在指定位置添加网格线.我对Python/Matlab不太熟悉,无法使用他们的文档页面来帮助 - 这些命令在Julia中有所不同.我想要一个基本的情节,两个轴上的网格线间隔为1:

using PyPlot
fig=figure("Name")
grid("on")
scatter([1,2,3,4],[4,5,6,7]) 
Run Code Online (Sandbox Code Playgroud)

帮助赞赏......

Gom*_*ero 7

PyPlot仅仅是一个接口Matplotlib,所以命令自定义网格是Matplotlib的命令.

以1为间隔(对于给定数据)在两个轴上配置网格线的一种方法是:

using PyPlot

fig=figure(figsize=[6,3])
ax1=subplot(1,1,1) # creates a subplot with just one graphic

ax1[:xaxis][:set_ticks](collect(1:4))  # configure x ticks from 1 to 4
ax1[:yaxis][:set_ticks](collect(4:7))  # configure y ticks from 4 to 7

grid("on")
scatter([1,2,3,4],[4,5,6,7])
Run Code Online (Sandbox Code Playgroud)

此代码在IJulia的笔记本中进行了测试,并产生以下输出:

绘图散射的输出1,2,3,4 x 4,5,6,7

使用PyPlot查看各种Julia绘图示例.

用Julia Version 0.4.3测试