Making plots look beautiful
131 views (last 30 days)
Hi, I made a plot which displays the condition of cars of a particular brand overtime.
What i would like to do is to make the plot beautiful in apperance for presentation. I tried movmean, smoothing, choosing larger time intervals to avoid the jittering of the data points. But none of them helped me. Can anyone suggest me an idea on how to get this done?
Plot is attached
Luna on 14 Feb 2019
Edited: Luna on 14 Feb 2019
I have just created a dummy data and plot them for you. You must check the line properties in documentation here the link:linespec
Please read comments carefully:
%% some random integer arrays 10x1
carsShowRoom = randi(20,10,1);
onRoad = randi(20,10,1);
good = randi(20,10,1);
bad = randi(20,10,1);
%% Time vector 1x10
time = 1:10;
hold on; % holds the axes
hPlot1 = plot(time,carsShowRoom); % hPlots are the plot handles, you can either change the properties from the handle object of the line or you can define them inside the plot function with 'propertyname',value pairs.
hPlot2 = plot(time,onRoad);
hPlot3 = plot(time,good);
hPlot4 = plot(time,bad);
hPlot1.LineStyle = '--'; % changes the line style
hPlot1.LineWidth = 2; % changes the line Width, you can get thin lines as you wish.
set(hPlot1, 'Marker', 'o'); % you can also use set function to set a property, definetely works like above. Marker adds a marker with shape you put. All of these informations are in the linespec link.
hPlot1.MarkerSize = 10;
hPlot1.MarkerEdgeColor = [0.85 0.47 0.32]; % Marker outside boundaries color
hPlot1.MarkerFaceColor = [0.1 0.25 0.89]; % Marker inside filling color
%% Note: To make your plot look beautiful use smooth colors not the defined 'r','b','c' colors they are way too bright.
% You can also use RGB color codes you can find on the internet but just be sure that Matlab gets color codes from 0 to 1 and RGB codes from 0 to 255. So you should interpolate it.
% For ex:
ColorCode = [148 130 78]./255; % Dividing 255 gives you the 0-1 value.
hPlot2.Color = ColorCode;
hPlot1.Color = 'c'; % As I said above don't use these bright colors.
%% Another important note:
% You can also use get method to see what properties and methods are defined for the line object
%% gives you the below result:
Annotation: [1×1 matlab.graphics.eventdata.Annotation]
Children: [0×0 GraphicsPlaceholder]
Color: [0 0.4470 0.7410]
MarkerIndices: [1 2 3 4 5 6 7 8 9 10]
Parent: [1×1 Axes]
UIContextMenu: [0×0 GraphicsPlaceholder]
XData: [1 2 3 4 5 6 7 8 9 10]
YData: [7 10 16 3 3 6 11 20 15 7]
ZData: [1×0 double]
You can also add legend and change legend location, orientation, etc... See that link: legend
I hope all these informations are useful. Just try this with running each line one by one in debug mode and see what changes in your plot figure. So you can change every property and decide what looks beautiful.
-You can use grid, xlabel and ylabel (with editing their font size, font color and font type, etc...).
-To save your figure with high resolution (I am telling this because the plot you attached has a very low resolution-you can see what I plotted below), use File Menu left top of the figure and save as .png format for high resolution to use in your MS Office.
If you still have any other questions, I can help.
More Answers (2)
Bjorn Gustavsson on 14 Feb 2019
You shouldn't manipulate your data that way. Your counting data is statistically "perfect" so you have to treat it as such, you could try to plot the data in different ways. Perhaps using stairs, or plot without the line:
Or take a look at some examples with bar-graphs...
atharva aalok on 17 Oct 2021
Edited: atharva aalok on 17 Oct 2021
Please refer the following Plotting Template:
The above is an easy to follow Beginner Friendly template.
The idea is to create Professional Standard Plots within seconds without a steep learning curve and with consistency.
It also offers a wide range of preset Color Codes (please refer the attached image for the Color Palatte)