Parallelplot hiding y values on graph

6 views (last 30 days)
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.

Accepted Answer

Adam Danz
Adam Danz on 29 Mar 2021
Edited: Adam Danz on 20 Sep 2023
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 Comments
Adam Danz
Adam Danz on 31 Mar 2021
Edited: Adam Danz on 1 Apr 2021
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 on 3 Apr 2021
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.

Sign in to comment.

More Answers (0)

Categories

Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!