banner



How To Set A Custom Tick Interval App Designer

I am using UIAxes in app desiger to display images and graphs as specified by the user. The images work perfectly, using the answer here

https://www.mathworks.com/matlabcentral/answers/360670-imshow-in-app-designer-image-size-doesn-t-fit

However, I am having issues with the graphing aspect. It appears that MATLAB is scaling the figure y-axis based upon the differences in the y-data plotted.

Graphs1.JPG

In most cases, I can live with this since the data is still legible. However, changing what the x-axis represents (which is the whole point of graphing) can end up with some very bad results.

Graphs3.JPG

This is completely illegible. Furthermore, for an unknown reason, the last two graphs cut out my ytitle (the code is the same line for line, only variables change, and it works elsewhere.

Making the issue weirder, if I graph a single number (which I would assume would change the size of the yaxis to nothing from the above examples) ends up with a very nice looking graph…

Graphs4.JPG

Things I have tried:

Increasing the size of the plot in the same way as the images in the answer above

Scaling the data so that x-axis and y-axis will always be the same range (i.e. both will be from 0-80 even if the raw data is from 2-2.5 on the y-axis)

Trying to alter the answer here to work with appdesigner (it errors btw)

app.UIAxesS1.Units = 'normalized';

app.UIAxesS1.Position = [0 0 1 1];

Changing the dataAspectRatio and PlotBoxAspectRatio in the axes properties tab and setting them to manual (has no effect)

Graphs5.JPG

Using the set position function to change the position of the plot

h = plot(….)

set(h,'Position',[0 0 1 1]) This one says it cannot work on a line property

set(app.UIAxes,'Position',[0 0 1 1]) This one just changes the UIAxes to fill the entire figure and doesn't change the plotted data

I am sure there is a super stupid error that I am making with parent/children things, but I am not sure what is happening. If anyone would like the other code that manipulates it for the images I can post that, but this scaling issue happens even without displaying any images. Thank you to anyone who has made it this far

Code to graph the data (xAxis, yAxis are my data points). Note: The ylim and xlim is the way I got enough room for my data labels

                      

plot(app.UIAxesS2, xAxis, yAxis(2,:), 'k*--' ); % to plot the data in xAxis and yAxis variables

title(app.UIAxesS2, []); % Removing title, adding axis labels

xlabel(app.UIAxesS2, xlab);

ylabel(app.UIAxesS2, 'Kt Values' );

xticks(app.UIAxesS2, xAxis); % Changing ticks and tick labels for xAxis

app.UIAxesS2.XAxis.TickLabels = xlabs;

text(app.UIAxesS2, xAxis - 0.1, yAxis(2,:) + 0.3, num2cell(round(yAxis(2,:),2))); %Adding data labels

app.UIAxesS2.YDir = 'normal' ; %Flipping direction of the y axis

ylim(app.UIAxesS2, [min(yAxis(2,:)) - 0.5, max(yAxis(2,:)) + 0.5]); %Refining the limits of the axis

xlim(app.UIAxesS2, [min(xAxis) - 0.5, max(xAxis) + 0.5]);

How To Set A Custom Tick Interval App Designer

Source: https://itectec.com/matlab/matlab-plots-in-app-designer-have-very-small-y-axis/

Posted by: smithrecognot40.blogspot.com

0 Response to "How To Set A Custom Tick Interval App Designer"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel