Octave 上的颜色条比例错误

发布于 01-17 05:18 字数 653 浏览 3 评论 0原文

我尝试创建一个图表,其中有一条线的颜色基于第三个变量。 为此,我使用散点图。 当我向该图中添加颜色条时,颜色条上报告的数据范围从零到最大值变化。 这是错误的,数据不是从零开始,因此图表上可视化的颜色是错误的。 这是我的代码:

load data;
figure(1);
plot(brd_1(:,1), brd_1(:,2), "color", "k");
hold;
axis([x_range(1), x_range(2), y_range(1), y_range(2)], "equal", "off");
plot(brd_2(:,1), brd_2(:,2), "color", "k");
colormap("viridis");
scatter(pnt_rl(:,1), pnt_rl(:,2), 8, v*3.6, "filled");
colorbar("EastOutside");
title("Speed [km/h]");

这里有尝试此代码所需的文件“数据”的链接:

https://1drv.ms/u/s!Av6EBKUGP49_gt1twhMuRsZ1PyVtrw?e=Mgat0d

I try to create a graph in which there is a line with colour based on a third variable.
To do that, I'm using scatter plot.
When I add colorbar to this plot, the data range reported on the colorbar vary from zero to max value.
This is wrong, the data don't start from zero, and so the color visualized on the graph are wrong.
This is my code:

load data;
figure(1);
plot(brd_1(:,1), brd_1(:,2), "color", "k");
hold;
axis([x_range(1), x_range(2), y_range(1), y_range(2)], "equal", "off");
plot(brd_2(:,1), brd_2(:,2), "color", "k");
colormap("viridis");
scatter(pnt_rl(:,1), pnt_rl(:,2), 8, v*3.6, "filled");
colorbar("EastOutside");
title("Speed [km/h]");

Here there is the link of the file "data" needed to try this code:

https://1drv.ms/u/s!Av6EBKUGP49_gt1twhMuRsZ1PyVtrw?e=Mgat0d

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

九歌凝2025-01-24 05:18:55

我的 scatter3 比例也错误。对我来说,做了以下工作:
caxis([地板(vmin), ceil(vmax)])。
看来这里需要整数。

这也有效: caxis([ single(min(v(:))), single(max(v(:)))])

I also had a wrong scale for scatter3. For me worked the following:
caxis([floor(vmin), ceil(vmax)]).
It seems integers are needed here.

This also worked: caxis([ single(min(v(:))), single(max(v(:)))])

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文