How do you format rotated text from clabel in MATLAB 2014b?

10 ビュー (過去 30 日間)
Ben Freireich
Ben Freireich 2014 年 11 月 7 日
編集済み: Neill Mackay 2017 年 2 月 28 日
The output of this code:
[C,h] = contour(peaks(1000),'r-');
clabel(C,h,'Color','r');
has changed between 2013a and 2014b. The 2013b out put would update the label color, but the line quality is poor. The 2014b gives excellent line quality, but leaves the text label color as black.
MATLAB 2013a
MATLAB 2014b
The help for 2014b says text formatting cannot be done if h is passed to clabel. However, it also (seemingly) gives no option for rotated labels if h is not passed. For example,
MATLAB 2014b with colors labels
[C,h] = contour(peaks(1000),'r-');
clabel(C,'Color','r');
Also, in 2014b clabel returns no output (handle) if h is not given as an argument. So I can't even access the handle to change formatting. I'm lost.
How can I have rotated colored labels for contours in MATLAB 2014b?
Thanks so much for help!

採用された回答

Doug Hull
Doug Hull 2014 年 11 月 10 日
Sorry this took a while to get answered. I have checked with our developers to confirm and this is a known incompatibility going into R2014b. We understand the frustration when capabilities disappear. We can say that improvements to clabel are being actively discussed and this is a use case of concern to us.
  1 件のコメント
Ben Freireich
Ben Freireich 2014 年 11 月 11 日
Thanks Doug!
That is a dissapointing answer, but at least I have an answer. It sounds like I'll have to do what I want to do here manually (i.e. w/ text and Rotate).
Is there any chance you could explain the benefit/purpose of the change to clabel?

サインインしてコメントする。

その他の回答 (2 件)

Mike Garrity
Mike Garrity 2014 年 11 月 11 日
> Is there any chance you could explain the benefit/purpose of the change to clabel?
Primary reason - Bugs. The API of changing properties on the text objects promised a lot more than it could actually deliver. Even in the simplest case of changing just the color of a text object, there were lots of problems where the contour object wouldn't realize what you'd done and mess things up. One common version of this bug was the case where you'd set the color of some of your text objects (e.g. the ones on the 0 contour level). After you got it the way you wanted it, the contour object would sometimes (e.g. during printing) decide that it could fit more labels in. When it did, it would often reuse the text objects you'd modified. It might either overwrite your colors, or worse, it might reuse the colored text objects for the labels on different levels. The result was a mess.
Secondary reason - Performance. We did a lot of work on improving the performance of contour in 14b. Wrangling those text objects was starting to become a major bottleneck. The current implementation uses a different approach.
The plan is to restore control over the label formatting with a new API which can actually deliver what it promises. Unfortunately that isn't ready yet.
  1 件のコメント
K E
K E 2015 年 3 月 18 日
Appreciate these kinds of straightforward answers.

サインインしてコメントする。


Rob Comer
Rob Comer 2015 年 6 月 5 日
You can avoid this problem, which is present in both R2014b and R2015a, using one of the workarounds available here: http://www.mathworks.com/support/bugreports/1114747. After downloading and installing the appropriate workaround, you will be able to control the appearance of contour label text with commands such as this:
clabel(C,h,'Color','red')
The workaround enables 12 properties that affect the appearance of contour labels: Color, FontName, FontSize, FontWeight, and 8 others. You will still have the benefits described in Mike's post from 11 Nov 2014.
  3 件のコメント
Patricia Handmann
Patricia Handmann 2017 年 2 月 9 日
so both contour and contourf is not working anymore - this is really bad, I hope You have an Idea how to solve this!!!
Neill Mackay
Neill Mackay 2017 年 2 月 28 日
編集済み: Neill Mackay 2017 年 2 月 28 日
I've just installed the same workaround for Matlab R2015a and have the same problem - contour and contourf no longer work. Please help!!

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeContour Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by