It's my first post in this blog. My purpose is to open a link of communication with other people that wants to get more experience in the use of MATLAB programming for technical and scientific reasons or even just for fun. My first issue to discuss is how ugly or pretty can be the plots created in MATLAB. During the last seven years, I always thought that it would be impossible or I would spent lot of energy to make pretty plots using MATLAB. I used to process the data in MATLAB. After that, I exported the processed results to text file, and finally, I made the plots in Microsoft Excel. Obviously, I was doing something wrong!
Today I'm posting a code to customize plots in MATLAB in order to make them more beautiful.
Look the plot below. This is one example of ugly plot made by using the default properties of MATLAB.
Fig 01. An example of plot made using the default plot properties of MATLAB. Ugly plot!
The plot in the Fig 01 was created using the following simple code:
x = 1:10; %Data from x domain
y = x+2; %Data from y domain
plot(x,y,'o'); %Function to plot the data
axis square %Command to make squared plots
xlabel('X') %Command to name the x domain
ylabel('Y') %Command to name the y domain
Look now the same data with some changes in plot properties.
Fig 02. An example of a plot with the same data in the Fig 01, but with changes in many plot properties.
The Fig 02 was made using the still simple code:
x = 1:10; %Data from x domain
y = x+2; %Data from y domain
plot(x,y,'o','MarkerEdgeColor',[0.1 0.1 0.1],'MarkerFaceColor',[0.8 0.8 0.8],'MarkerSize',12); %Function to plot the data. Here, I change plot properties of the color of the maker edge and marker %face and the marker size.
axis square
%Two lines below, I set the font name, font size, and the font weight. I did using my preferences.
xlabel('X','FontName','Times New Roman','Fontsize',18,'Fontweight','bold')
ylabel('Y','FontName','Times New Roman','Fontsize',18,'Fontweight','bold')
%Below, I changed many plot properties that in my opinion give more visibility to the graph
set(gca,'Box', 'off', 'TickDir', 'out', 'TickLength' , [.035 .035] , 'XMinorTick' , 'on', ...
'YMinorTick', 'on', 'YGrid', 'on', 'XGrid', 'on', 'LineWidth', 3, 'FontName', 'Times New Roman',...
'Fontsize',18, 'Fontweight','bold');
After you write the code to customize the plot, it is necessary only to apply the same code for new plots. I know that the beauty is in the eye of the beholder, and it doesn't matter if the Fig 02 is prettier than Fig 01, but with few more lines in your code you can change the quality of your data presentation.
Feel free to contact me about this post or other MATLAB issues by the e-mail givagosouza@gmail.com
The Casinos Of New Jersey: Where To Play and Win at the
ReplyDeleteThese 사천 출장마사지 casinos offer 고양 출장안마 the best 평택 출장마사지 games to its 거제 출장안마 players. 속초 출장마사지 At each of these casino sites, we recommend playing for real money.