Matlab border around figure - matlab

In attached image the output looks boring to me. Is it possible to have the subplots enclosed in a border?
Note: This question is not specific to publishing only but in general, say for exported images also.
Thanks
Postscript: I actually need this:

You can add a box like in here
making your code:
close all
figure()
padd=0.04
axes('Position',[padd padd 1-padd*2 1-padd*2],'xtick',[],'ytick',[],'box','on','handlevisibility','off')
subplot(1,2,1)
imagesc(magic(2))
subplot(1,2,2)
imagesc(magic(3))
This yields
And you can change the padd to be bigger or smaller

I obtained this just by plotting lines of different thickness 1.
The text was added with Inkscape though.

If I understand correctly what you want to do, you can obtain borders inside a figure using uipanels http://www.mathworks.com/help/matlab/ref/uipanel.html like this:
Code is:
u=uipanel('Title','MainPanel')
u1=uipanel('Parent',u,'BorderType','line','HighlightColor','k','Title','Subpanel 1','Position',[0,0,0.5,1])
u2=uipanel('Parent',u,'BorderType','line','HighlightColor','k','Title','Subpanel 2','Position',[0.5,0,0.5,1])
axes1=axes('Parent',u1)
imagesc(magic(2))
axes2=axes('Parent',u2)
imagesc(magic(3))
Of course you can change border widths, colors, titles and such

Related

If I have 4 coordinates making a rectangle, how can I color in that area?

I have 4 coordinates assigned to variables, so I would just like to colour in the rectangle that is created from these variables. I tried the fill function, but I cant gather much information from the example.
When I try to use:
fill(bottom left point, top right point,'g')
the figure it makes only shows a line between those points, and doesn't colour in the entire area.
I'm using MATLAB R2019b, if that helps.
Also, if its possible to fill the rectangle with a pattern instead, please let me know aswell.
Thanks in advance

Aligning axes of different sizes within a GUI

I have a trivial question but not able find a effective solution. I hope somebody could help me in this regard.
I currently have 4 different axes in a GUI. ax1(top left) and ax4(bottom left) should be aligned vertically and similarly ax2(top right) and ax4(bottom right) should be aligned vertically. (I have attached a sample image)
ax1 and ax2 are used to show images that are usually larger in size(~512x512) and ax3 & ax4 are used to display images of size ~43x512. Even though I created the axes with x-axis the same size when I display images they change size and not aligned anymore. No matter what images I display, I want the top and bottom images to of same x length and aligned always.
I tried to keep the XLim the same; XData the same but still doesnt work.
Any help is greatly appreciated.
Thanks, Bala
You can use the align function which is used to do just that. The calling syntax is as follows:
align(HandleList,'HorizontalAlignment','VerticalAlignment')
Therefore in you case, you could write something like this (Note that you wrote ax4 twice in your question, I guess you wish to align axes 1-3 and 2-4):
align([handles.ax1 handles.ax3],'VerticalAlignment','none', 'HorizontalAlignment','center')
and likewise for the other 2 axes:
align([handles.ax2 handles.ax4],'VerticalAlignment','none', 'HorizontalAlignment','center')

Change markers in dynamic plots

What I have:
hold on
for i =1:length(tspan)
var{i} = Tv(:,i);
str{i} = ['t = ',num2str(tspan(i)), ' s'];
plot(z,var{i},'DisplayName',str{i});
end
legend('-DynamicLegend');
This works perfectly (thanks to this), but it prints out all blue lines.
I tried to set up a colormap (the default) and use it like this, but the output was the same
plot(z,var{i},'DisplayName',str{i},'Color', colormap(i,:));
And I would also like to see different markers for each plot. How is it possible to change them?
EDIT
Thanks to ironzionlion I fixed the colors. How can I do the same with markers?
According to the post that you mention, you have to define that you will need i different colours in your plot. This can be done by using colors = hsv(i)
Your plot sentence will then be: plot(z,var{i},'DisplayName',str{i},'Color', colors(i,:));
Update
I am not aware of the existance of "markermap". You could fix the problem just by define upfront the different markers that you want (quick and dirty solution): mrk={'o','+','*','.'};
Then you will plot by selecting each time the corresponding marker:
plot(z,var{i},'DisplayName',str{i},'Color', cmap(i,:),'Marker', mrk{i});

include 4 images as different panels in matlab

I am trying to include 4 already present images into one new image, done and created in matlab, like a collage, with 4 images present adjacent to each other, bordering, in the new image. I really do not know where to start. Could you please help me here? In matlab?
Another options if you don't want white space between images is to combine the images into a single matrix.
ie:
image([I1 I2; I3 I4])
of course the images have to be the same size for this to work...
Actually, apart from What Hassan suggested, I was able to achieve my purpose easily using subplot and subimages.
Eg.
subplot(2,2,1)
imshow(I1)
subplot(2,2,2)
imshow(I2)
Thanks for your help :).

MatLab: displaying figures side by side

As when you use subplot to display plots side by side in the same window, I would like a similar function that can do the same for multiple figures. This works:
subplot(2,2,1)
and I am looking for something like this:
subfigure(2,2,1)
Does a build-in function with this advantage exist?
You could write one such function yourself. The idea is to get the screen size:
get(0,'ScreenSize')
then divide it up into sub-regions according to the input parameters. You would also need to account for margins in-between.
Another idea:
create an invisible figure (preferably same aspect ratio as the screen)
call subplot inside it
capture the position of the created axis
delete figure
scale the position captured to fit the screen size, and use it to create the actual figures.