How do I change the appearance of a tick label over a number of iterative values through a pre-exisitng tick label?
Ältere Kommentare anzeigen
I have a plot which updates to create a video file. It plots a sweeping signal from 1-11GHz. I want to add the label of the signal to the yaxis (surface plot) at each point so i use
set(gca, 'YTick', unique([Sweep(i).Sig_Freq, get(gca, 'YTick')]));
Sweep(i) is each point in the sweep and its Sig_Freq field is the frequency of the signal. As you can imagine Sweep(i).data is anothe field which contains the corresponding data and I plot with:
s=surf(sx,sy,Sweep(i).data(7).WRspice(1:621,:).*1e6)
I then updata the ticks to give me the signal uniquely with
set(gca, 'YTick', unique([Sweep(i).Sig_Freq, get(gca, 'YTick')]));
I first would like to be ablet to adjust the signal label for example smaller font size and maybe red in colour so for all frequencies 1-10 maybe i can set yticklabel(2) to do that. But then how do i update that when yticklabel(2) is the 10GHz tick and the signal has swept over 10-11. I understand I could achieve this semi-manually by just uting a for sig_Freq<10 ....... then something else but i may want to change this for multiple different purposes and zoom in on plot thus changing the yticklabels etc..
An idea I had for what I would like is a perhaps some clever way of labelling this specific label so that at the point I add it to the ytick labels it has a label then I can always adress this partricular tick bsaed on its label or someting like that. Is this possible? and if so how?
What I want to achieve is a way to programtically add a specific ytick and yticklabel to a plot, then move this tick and label with subsequent updated plots through a pre-existing static ylabel and format this individual added yticklabel appearance for each plot without prior knoweldge of exactly where the static ylabel is. My current code looks like this and I am trying to load the Sweep structure but it is too large and I will look to make a reasonable MWE in the near future.
Akzeptierte Antwort
Weitere Antworten (1)
Image Analyst
am 5 Apr. 2020
See attached demo that shows you how to control appearance of lots of things on an axes control.
% Demo to make a black graph with red Y axis, green X axis, and yellow grid.
% Initialization steps:
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clearvars;
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 24;
% Create sample data.
X = 1 : 20;
Y = rand(1, 20);
plot(X, Y, 'gs-', 'LineWidth', 2, 'MarkerSize', 10);
grid on;
title('Y vs. X', 'FontSize', 12);
% Make labels for the two axes.
xlabel('X Axis');
ylabel('Y axis');
% Get handle to current axes.
ax = gca
% This sets background color to black.
ax.Color = 'k'
ax.YColor = 'r';
% Make the x axis dark green.
darkGreen = [0, 0.6, 0];
ax.XColor = darkGreen;
% Make the grid color yellow.
ax.GridColor = 'y';
ax.GridAlpha = 0.9; % Set's transparency of the grid.
% Set x and y font sizes.
ax.XAxis.FontSize = 15;
ax.YAxis.FontSize = 24;
% The below would set everything: title, x axis, y axis, and tick mark label font sizes.
% ax.FontSize = 34;
% Bold all labels.
ax.FontWeight = 'bold';
hold off

Kategorien
Mehr zu Axis Labels finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

