Parallelplot hiding y values on graph

16 次查看(过去 30 天)
The parallelplot graph below looks very confusing. Is there a way that i can hide exponential numbers ? I'd like to hide every exponential number on y axes of each date.

采纳的回答

Adam Danz
Adam Danz 2021-3-29
编辑:Adam Danz 2023-9-20
I agree with Star Strider's advice to scale the data. That will still result in y-ticks for each YRuler.
Here are two alternatives, both of which use undocumented methods tested in r2021a but may not work in future releases.
Demo 1: remove ytick for all YRulers except the first
Remove the yticks for all YRulers except the one on the far left. If the YRulers have different scales this will be misleading unless you document the scales somehwere on the figure.
% Demo data & plot
figure()
data = rand(100,5).*[1 1e-06 1e-08 1e08 1e10];
p = parallelplot(data);
% Undocumented: access YRuler and avoid warning
origState = warning('query', 'MATLAB:structOnObject');
cleanup = onCleanup(@()warning(origState));
warning('off','MATLAB:structOnObject')
S = struct(p);
clear('cleanup')
% Remove yticks for YRulers except the first
% Note that the first and second YRuler control the left-most YRuler.
drawnow() % make sure labels are written first
set(S.YRulers(3:end), 'TickLabels', '')
See addendum below for an additional required step!
Before and after:
Demo 2: change exponent notation
% Demo data & plot
figure()
data = rand(100,5).*[1 1e-06 1e-08 1e08 1e10];
p = parallelplot(data);
% Undocumented: access YRuler and avoid warning
origState = warning('query', 'MATLAB:structOnObject');
cleanup = onCleanup(@()warning(origState));
warning('off','MATLAB:structOnObject')
S = struct(p);
clear('cleanup')
% Set ytick notation for the YRulers in axis number 'n' from the left.
% Note that the first and second YRuler control the left-most YRuler.
drawnow() % make sure labels are written first
n = 2; % axis number 2
set(S.YRulers(n+1), 'TickLabelMode', 'auto', 'Exponent', -3)
% or set the TickLabelFormat
set(S.YRulers(n+1), 'TickLabelMode', 'auto', 'TickLabelFormat', '%.3f')
See addendum below for an additional required step!
Addendum: prevent auto restoration of ticks
The changes above will be lost as soon as the axes are changed in any way (e.g. resize figure). To prevent the restoration of the original ticks, disable the MarkedClean listener. This should all go toward the end of your plotting code and I haven't explored what else this may effect!!
S.AutoListeners__{1} % view the MarkedClean listener.
ans =
listener with properties:
Source: {[1×1 ParallelCoordinatesPlot]}
EventName: 'MarkedClean'
Callback: @(~,~)markedCleanCallback(pc)
Enabled: 0
Recursive: 0
% Disable the MarkedClean listener
S.AutoListeners__{1}.Enabled = false;
  17 个评论
Adam Danz
Adam Danz 2021-3-31
编辑:Adam Danz 2021-4-1
Firstly, don't use live script for development. Use it to create demos and for instructional purposes but use regular m files otherwise. They are much faster and do less buggy.
Secondly, I'm using r2021a and with every release live script gets better, especially in 21a.
Gorkem Akgul
Gorkem Akgul 2021-4-3
Thanks for the effort @Adam Danz
I'd like to ask one last thing. When i group the data, the groupvariable div is very close to graph. Can i change its location ?
I tried some approaches with set function but didn't work as usual. Also I'm gonna apply the advices of you about livescripts and update my version of MATLAB.
Livescript still shows the YRulers but i save the graph as a png file and add it into livescript.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Graphics Performance 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by