Parallelplot hiding y values on graph
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
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.

採用された回答
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 件のコメント
Gorkem Akgul
2021 年 3 月 30 日
I used the code but it didn't work. Probably it's because that i use 2020a version. Thank you for the answer. I'm gonna try to change the notation from scientific to the full number in digits. Also as you said, scaling can be a good option. I do think there is supposed to be a way of hiding yRulers, it is interesting that there is not.
Gorkem Akgul
2021 年 3 月 30 日
How can i change the scientific notation ?
> I used the code but it didn't work.
Could you share the entire error code if there was an error? If there wasn't an error, can you explain what what happened?
I just tested it in r2020b (I don't have r2020a on this machine) and it worked.
Did you try running my example exactly as it is?
Adam Danz
2021 年 3 月 30 日
> How can i change the scientific notation ?
See Demo 2 in my updated answer. The last 2 lines show two different ways to change the tick style.
Gorkem Akgul
2021 年 3 月 30 日
I firstly edited my codes and make them similar to yours but there was neither a change on the graph nor an error . Afterwards, i run the same code you send first and no error occured yet there wasn't any change on the graph.
Are you sure you included the drawnow command? Without it, there will be no change.
Please show me what S.YRulers looks like on your end.
Gorkem Akgul
2021 年 3 月 30 日
Another interesting thing is that the second demo doesn't work either. I used the online version of matlab, i think it is 2021a. When i use the set code it just convert it from scientific to digit notation just for a moment then made it exponential again.

It showed the output below just for a moment. Then it converted the one above.

Gorkem Akgul
2021 年 3 月 30 日
I used almost the same code. It shows the second graph in decimal just for a second then converts it as exponential.


I just tested my answer in r2020a and both demos worked as expected.
If your processer is very fast, add a pause() after drawnow to make sure the figure renders before the YRuler properties are set.
drawnow(); pause(0.2) % increase if necessary but this should be sufficient.
Also, instead of posting screenshots of code, it's much more helpful to copy-paste the code as text and format it using the text/code toggle button.
Gorkem Akgul
2021 年 3 月 30 日
The first demo was actually working too. It just happens so fast that i cannot catch. After using the code below i was able to see that YRulers disappeared as i wanted them to be (just for a little while). When i use pause() after drawnow, no matter how much i raise the pausing duration, nothing has changed but i could see that YRulers were disappeared for a while after i use pause() after set function.
% 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', '')
pause(1)
I see what's happening. The solution works until there is a change to the axes, then the ylabels return. For example, if the figure is maximized after the ticks are removed, then the axis-resize evokes the restoration of the ticks. There must be a listener that's doing that. I can dig a little deeper to see if there's another way around this.
BTW, the pause should go immediately after the drawnow so the ticks can be generated before they are changed. Pausing after the ticks are changes doesn't do anything except delay the reversion.
Adam Danz
2021 年 3 月 30 日
Ok, I've updated my answer. See the addendum at the bottom.
I've disabled the MarkedClean listener and briefly tested it. The altered ticks are maintained when maximizing the figure. Does this fix the problem on your end as well?
Gorkem Akgul
2021 年 3 月 30 日
Firstly I'd like to thank you one more time @Adam Danz because you spent quite a time to solve this problem out. It worked :) But there is something that i'd like to say.
When you figure out what the problem is, i was also about to get it. When i run the code with F9 the graph form looked similar to what i wanted but when i change the size it came back to previous form with YRulers.
When i disabled the listener by using your code, i still saw the YRulers on the graph( i see them on livescript and) Seeing the YRulers on livescript graph tricked me and i was almost gonna write that it didn't work. When i run the code with F9 and get a graph form the YRulers doesn't seem just like i wanted. Why do you think i can see the YRulers on livescript graph, whereas, i don't see them on windows form graph ?
Adam Danz
2021 年 3 月 30 日
Hmmmm that's interesting.
When I run the first demo in my answer in LiveScript it prouduces two plot: one immediately after p=parallelplot(...) with the yaxis tick labels and one at the end without the yaxis ticks. I've attached the mlx file.
Live scripts works differently than regular scripts and I don't know enough about what's happening in the background to understand the problem in live scripts. My guess is that the struct(p) command copies the handle and is interpretted as a new figure by LiveScript but I may very well be wrong (I'd love to know).
Also, any of the following are possibilities:
- The undocumented methods I've found aren't the best approach to solve the problem
- My solution is incomplete and addiitonal properties need adjustment
- As with all undocumented methods, they are undocumented for a reason and may perform differently under different contexts and versions of Matlab.
To be honest, I have never even heard of parallelplot() before this question (introduced in r2019a) which is a main reason I enjoy participating in this forum.
Gorkem Akgul
2021 年 3 月 30 日
It's a quite nice way of graphing something for each month. I learnt about parallelplots thanks to an online matlab course and i thought i make use of it for this example.
I'm not totally sure but last year i think there was an error that took my time so long to sort out which was because of the difference between live scripts and regular scripts. There are really some differences between them. What's interesting is that, even though we both are using livescripts, in my case i cannot see the graph i want when i use it so i need to draw it in a regular script or run the code with F9, whereas, you can use livescript. I also downloaded your livescript too and run it. Just like my case it persisted on showing YRulers in livescript. There can be some differences between live scripts and regular scripts but it is unlikely that there are differences between two livescripts. I also run your code on online version of MATLAB and it did the same. Interesting....
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
2021 年 4 月 3 日
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 件)
カテゴリ
ヘルプ センター および File Exchange で Creating, Deleting, and Querying Graphics Objects についてさらに検索
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
