如何将轴移动到图表中心? [英] how to move axes to center of chart?

查看:70
本文介绍了如何将轴移动到图表中心?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在坐标系上绘制一个函数,该函数的原点位于屏幕中心(或靠近中心的某处,但不一定位于中心),并且我需要绘制轴以便它们在原点处交叉.轴上也应该有标签和刻度线以及箭头.

I need to plot a function on a coordinate system that has its origin at the center of the screen (or somewhere near the center, but not necessarily in the center) and I need to draw axes so that they cross at the origin. Axes should have labels and tics as well, and arrows.

我不知道如何有效地执行此操作,到目前为止,在我的代码中,我为tic手动设置了偏移量,并且还使用偏移量手动绘制了箭头.我还在轴标签上设置了偏​​移量.所有这些都很脆弱,偏移量会根据终端设置而变化.

I have no idea how to do this efficiently, so far in my code I manually set offsets for my tics, and draw arrows manually using offsets as well. I also set offsets on the axes labels. All this is very fragile, and offsets change depending on the terminal settings.

有人可以帮助我提供示例代码或说明,以正确的方式做到这一点吗?

Would someone please help me with a sample code or an explanation how to do this the right way?

推荐答案

好吧,使用_zeroaxis是获取tic和标签的正确"方法:设置_range可以使对称性达到0,0中心...并且一旦知道_range,就可以手动绘制箭头.

Well, using _zeroaxis is the "right" way to go to get the tics and labels in: setting the _range gives you the symmetry to make 0,0 centre ... and once you know the _range, you can draw arrows on manually.

set xzeroaxis
set xtics axis
set xrange [-10:10]
set arrow 1 from -9,0 to -10,0
set arrow 2 from  9,0 to  10,0

set yzeroaxis
set ytics axis
set yrange [-1:1]
set arrow 3 from 0,-.9 to 0,-1
set arrow 4 from 0,.9  to 0,1

set border 0

plot sin(x)

这篇关于如何将轴移动到图表中心?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆