MatLab:对数z轴和bar3的奇怪显示 [英] MatLab: Weird display of logarithmic z-axis and bar3

查看:272
本文介绍了MatLab:对数z轴和bar3的奇怪显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用bar3图显示3d直方图.使用相对于x轴,y轴和z轴的线性比例可得出以下结果:

I want to display a 3d histogram using bar3plot. Using linear scales with respect to x-, y-, and z-axis gives the following result:

但是,由于z值的间隔非常大,因此我想使用对数z轴,以便较低的z值也可见.但是,将z轴设置为set(gca, 'ZScale', 'log');的对数会产生以下图,看起来不太好:

However, since the z-values have a very large interval I want to use a logarithmic z-axis such that the lower z-values are also visible. However, setting the z-axis to logarithmic with set(gca, 'ZScale', 'log'); yields the following plot, which does not look good:

我需要设置一些额外的选项吗?还是一个已知的错误?

Is there some extra option I need to set or is it a known bug?

提前谢谢!

推荐答案

这是Matlab中使用非标准绘图功能或对绘图进行修改(例如

This is a fairly common problem with log axis in Matlab with non standard plotting functions or modifications to plots, eg trying to use transparency with log axis

bar3 生成的图需要OpenGL渲染器其中不支持对数轴.

The plot generated by bar3 requires the OpenGL renderer which doesn't support logarithmic axis.

通过转换数据并设置刻度线/标签来模拟日志轴

Mimic log axis by transforming data and setting tick marks / labels

以下创建带有对数轴的图以获取刻度线和标签,清除轴,然后再次开始绘制具有变换的刻度线和标签的数据的对数.

the following creates the plot with log axis to get tick marks and lables, clears the axis then starts again plotting the log of the data with transformed tick marks and labels.

bar3(Z);
set(gca,'Zscale','log')
ticks=get(gca,'Ztick');
ticklabel=str2num(get(gca,'ZtickLabel'));
set(gca,'Zscale','linear')
cla

bar3(log(Z));
set(gca,'Ztick',log(ticks));set(gca,'ZtickLabel',10.^ticklabel)

只有刻度标签的格式丢失.

only the formatting of the tick labels is lost.

此方法不适用于0-1范围内的0-1范围内的值,因为绘图已反转并且出现负数导致log出现问题,无论哪种情况,都需要进一步的转换.但是在给定的情况下查看图中的数据应该不是问题.

This method does not work well for values in the range 0-1 with bar3 as the plot is inverted and negative causes issues with log in either case further transforms would be required. however looking at the data in the plots given this should not be an issue.

这篇关于MatLab:对数z轴和bar3的奇怪显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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