【问题标题】:Why are the scatterplot colors in MATLAB R2021a different?为什么 MATLAB R2021a 中的散点图颜色不同?
【发布时间】:2021-07-31 05:39:37
【问题描述】:

我已经安装了Matlab R2021a,当我对一个向量运行命令scatterplot时,我得到一个如下图:

我的意思是黑色和黄色。但是旧版本的默认颜色如下:

我的意思是颜色是白色和蓝色。

我的担心,我需要我的 MATLAB 显示旧版本中的图形颜色,我的意思是白色和蓝色。

【问题讨论】:

  • 您是否配置了深色主题?也许您的窗口管理器正在反转所有颜色?
  • @CrisLuengo 但其他绘图方式照常以白色和黑色显示图形,例如,当使用命令 plot 和 stem 时,图形以白色和黑色显示。这些颜色仅在使用命令 scatterplot 时显示。 .另外,我在同一台PC上安装了另一个matlab,MATLAB2014b,它像往常一样以白色和黑色显示散点图。
  • scatterplot 不是标准的 MATLAB 函数。 scatter 是。您正在使用某种自定义绘图功能。
  • 我的数据是一个长度为1000的向量,使用scatterplot(data)时直接绘制数据,但使用scatter(data)时,报错Error using scatter (line 54) Not enough input arguments
  • 看来你有复数。在这种情况下,您还可以使用scatter 绘制散点图:scatter(real(s), imag(s), 6, 'filled');

标签: matlab plot matlab-figure scatter-plot scatter


【解决方案1】:

release notes 中所述,R2021a 中的行为确实发生了变化:

对使用eyediagramscatterplot 函数生成的绘图进行视觉外观更新。
eyediagramscatterplot 函数现在默认提供黑色绘图背景。

您可以通过修改轴/图形的属性来根据需要更改颜色,如下所示:

%Taking the example from the documentation
d = (0:63)';
s = qammod(d,64);
scatterplot(s);

%Modifying the colors
h=gca;                %Axis handle
h.Title.Color='k'     %Color of title
h.Children.Color='b'; %Color of points
h.YColor='k';         %Y-axis color including ylabel
h.XColor='k';         %X-axis color including xlabel
h.Color ='w';         %inside-axis color
h.Parent.Color='w'    %outside-axis color

没有修改,我们得到这个:

修改后,根据需要,我们得到这个:

【讨论】:

  • 谢谢!是否可以默认设置此颜色。这意味着在运行scatterplot(s)时,黑/白数字显示,而不是每次运行您提供的代码。
  • @Zeyad 这是可能的,但它需要覆盖/覆盖原来的 scatterplot 函数,所以我建议不要这样做。如果你想编写一个在所有版本中都给你相同结果的代码,你也可以在旧版本中运行带有修改的代码,你仍然会得到想要的结果。或者,您可以使用scatter 获得相同的结果,例如,对于上面代码中显示的示例,您可以使用scatter(real(s),imag(s),6,'filled'); 获得类似的结果,但scatter 默认情况下不提供这些轴标签/标题,但这可以是调整。
猜你喜欢
  • 2019-03-14
  • 1970-01-01
  • 2018-09-29
  • 2018-08-24
  • 1970-01-01
  • 1970-01-01
  • 2015-06-13
  • 2019-11-03
  • 2018-01-14
相关资源
最近更新 更多