如何在八度中绘制和显示正方形? [英] How to plot and display a square in Octave?

查看:108
本文介绍了如何在八度中绘制和显示正方形?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法在八度中绘制正方形. 我无法强制按比例缩放轴,因此我得到一个矩形:

I cannot achieve to plot a square in Octave. I cannot force equally scaled axes, so I am getting a rectangle instead:

以下试验无效:

x = [0, 1, 1, 0, 0]';
y = [0, 0, 1, 1, 0];
plot(x, y), axis equal, axis([-1,2, -1,2])
% figure('Position', [10,10,100,100]); %[startx,starty,width,height]
% plot(x, y)

可能我需要指定一个固定的窗口大小 缩放轴.当第一个这样的显示窗口时,我会感到满意 将显示正确的正方形.豪华的解决方案将使窗户成为可能 (或其内容) 不可交互式调整大小.

Probably I would need to specify a fixed window size and equally scaled axes. I would be satisfied, when the first such display window would show a correct square. A luxury solution would make the window (or its content) not interactively resizable.

备注:

  1. 我在Windows XP上具有Octave 3.2.4.
  2. Stackoverflow 中的建议 不起作用.
  1. I have Octave 3.2.4 on Windows XP.
  2. The suggestion in Stackoverflow does not work.

推荐答案

我认为这是Gnuplot的windows输出设备存在的问题.与wxt设备进行比较:

I believe this is an issue with Gnuplot's windows output device. Compare it against the wxt device:

# Gnuplot, wxWidgets terminal
set terminal wxt size 200,400
set size ratio -1        # set size square
plot x

# Gnuplot, Windows terminal
set terminal windows size 200,400
set size ratio -1        # set size square
plot x

请注意,对于"win终端",大小会影响图形大小,包括窗口标题栏和状态栏,而对于"wx终端",它只会设置内部绘图区域

Note that for the "win terminal", size affects the figure size including window title bar and status bar, while for the "wx terminal" it only sets the inner drawing area

不幸的是,当我在八音度中尝试过此操作时,它仍然不是应有的功能适用于两种终端类型.实际上,问题是使用set(gcf,'position',[..])调整图形大小没有效果:

Unfortunately, when I tried this in Octave, it still was not what it should be for both terminal types. In fact, the problem is that resizing the figure using set(gcf,'position',[..]) had no effect:

# Octave, backend=Gnuplot, terminal=wxt/windows
graphics_toolkit gnuplot     # backend gnuplot
setenv('GNUTERM','wx')       # wx/windows
figure, set(gcf,'position',[100 100 200 400])
plot(-10:10, -10:10, 'r'), legend('x')
axis([-10 10 -10 10])
axis equal                   # axis square

因此,我不得不使用鼠标手动将图形调整为指定的大小(200,400)(是的,我实际上拉了虚拟标尺并测量了像素!).最后调用refresh命令重新绘图:

Therefore, I had to manually resize the figures using the mouse to the specified size (200,400) (yes, I actually pulled a virtual ruler and measured the pixels!). Finally call refresh command to replot:

好消息是,一旦正确设置了图形尺寸,axis equal就适用于两种端子类型.

The good news is that once you correctly set the figure size, axis equal is working for both terminals types.

另一方面,新的FLTK后端运行正常,没有任何黑客攻击,因此您可能想要切换到它:

On the other hand, the new FLTK backend is behaving correctly without any hacks, so you might wanna switch to it:

# Octave, backend=FLTK
graphics_toolkit fltk        # backend fltk
figure, set(gcf,'position',[100 100 200 400])
plot(-10:10, -10:10, 'r'), legend('x')
axis([-10 10 -10 10])
axis equal

作为参考,这是MATLAB输出:

For reference, here is the MATLAB output:

%# MATLAB
figure, set(gcf,'position',[100 100 200 400])
plot(-10:10, -10:10, 'r'), legend('x')
axis equal
axis([-10 10 -10 10])

这篇关于如何在八度中绘制和显示正方形?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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