Clear Filters
Clear Filters

How can I change the color of each axes label in a radar graph by using some condition

19 views (last 30 days)
I want to plot a radar graph with different color of the axes label. I attach the excel sheet in which I want to plot the data (D1,D2, ... D15), but the background of the label should be change according to the sample coloum. e.g if sample is 0 the color of D1 label should be black, if the sample is 10 then D2 label color should be green if the sample is 25 then D3 label color should be red and so on... I tried but the color of all label changes I want to change each label color accroding to the sample conditions.

Answers (2)

Image Analyst
Image Analyst on 13 Feb 2023
See my attached demo. See how you can get virtually everything on your graph and apply properties to it, like font size, color, etc.
  2 Comments
Adil Sardar
Adil Sardar on 14 Feb 2023
Thank you for your time and effort, but I want to change the color by using some condition not manually. for one label we can do it by the method you used. but I have many labels from D1, D2 ...... D15 and may be later it will increase. I want to change the background of each label according to the samples. in the given pic I change the background of D1 .... D17 but I want to change the color of each by using the condition.. I use if else conditiion,
for i = 1 : length(sample)
if sample(i) <= 10
label_colr = 'r';
elseif sample(i) <= 30
label_colr = 'g';
elseif sample(i) <= 50
label_colr = 'k';
end
end
plot (x,y, 'backgroundColor', label_colr)
I am doing some mistake due to which the compiler only select the last value due to which the whole labels become same color.
if you can help me by using the condition then I will make it.
Thank you

Sign in to comment.


Walter Roberson
Walter Roberson on 14 Feb 2023
spider_plot_class supports the following axes label options:
  • AxesLabels -- specify the labels
  • AxesLabelsEdge
  • AxesInterpreter
  • AxesLabelsRotate
When an axes label gets created, it gets created as a text() object. with the label edge set according to AxesLabelsEdge, and the text background color set according to the Background property. However, in the code AxesLabelsEdge can only be a single specification (not one per axes) and Background is used for a number of things, not just axes labels.
The created labels are stored in the object private property AxesTextLabels. The code has no provision to return those to the user.
So... in order to do this you have three choices:
  • write your own spider plot chart that acts like you want; or
  • modify the spider plot code from the file exchange to support one background per axes, separate from ; or
  • take the object returned from spider_plot_class(), and struct() it so that you can gain access to AxesTextLabels object property, after which you can set the Background property of each text object in the array.

Categories

Find more on Polar Plots 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!