Making plots look beautiful

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

6 Comments

Could you please attach your data? And also what do you mean by look beautiful? Data manipulation or physical appereance like color, linewidth,etc?..
The data size is very large. I am not able to attach the data after compressing the file too. I mean physical appearance.
Use interp1() with 'spline' method if your only concerned about appearance.
Why use interp1? Only to produce graphs implying fractions of vehicles are out in traffic?
madhan ravi
madhan ravi on 14 Feb 2019
Edited: madhan ravi on 14 Feb 2019
I meant if OP is concerned about appearance!
OP had a discrete counting-number data-set that was sampled at discrete times, and not with discretization noise. That's what the graph should present, in as clear and neat way as possible. Using smoothing or spline interpolation hides that data, even though the curves might look neater.

Sign in to comment.

 Accepted Answer

Luna
Luna on 14 Feb 2019
Edited: Luna on 14 Feb 2019
Hello Hari,
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;
figure;
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
get(hPlot1)
%% gives you the below result:
AlignVertexCenters: 'off'
Annotation: [1×1 matlab.graphics.eventdata.Annotation]
BeingDeleted: 'off'
BusyAction: 'queue'
ButtonDownFcn: ''
Children: [0×0 GraphicsPlaceholder]
Clipping: 'on'
Color: [0 0.4470 0.7410]
CreateFcn: ''
DeleteFcn: ''
DisplayName: ''
HandleVisibility: 'on'
HitTest: 'on'
Interruptible: 'on'
LineJoin: 'round'
LineStyle: '-'
LineWidth: 0.5000
Marker: 'none'
MarkerEdgeColor: 'auto'
MarkerFaceColor: 'none'
MarkerIndices: [1 2 3 4 5 6 7 8 9 10]
MarkerSize: 6
Parent: [1×1 Axes]
PickableParts: 'visible'
Selected: 'off'
SelectionHighlight: 'on'
Tag: ''
Type: 'line'
UIContextMenu: [0×0 GraphicsPlaceholder]
UserData: []
Visible: 'on'
XData: [1 2 3 4 5 6 7 8 9 10]
XDataMode: 'manual'
XDataSource: ''
YData: [7 10 16 3 3 6 11 20 15 7]
YDataSource: ''
ZData: [1×0 double]
ZDataSource: ''
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.
Additional Edit:
-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.

5 Comments

@Luna, thank you very much for the help with detailed description.
Your welcome :)
@Luna, i would like to ask one more question. I would like to add the legend of this plot in a horizontal way just below the X-axis to save space. I added a line of code to perform this. But i am not able to see the legend. Can you give an advice.
legend(leg,'Orientation','horizontal','Location','SouthOutside')
what is your leg variable? You should define it with a cell array and you must have N elements in the cell array where N is the number of your plot lines.
leg = {'line1','line2','line3'};
legend(leg,'Orientation','horizontal','Location','SouthOutside');
See this example in the documentation of legend:
x = linspace(0,pi);
y1 = cos(x);
plot(x,y1)
hold on
y2 = cos(2*x);
plot(x,y2)
y3 = cos(3*x);
plot(x,y3)
y4 = cos(4*x);
plot(x,y4)
hold off
legend({'cos(x)','cos(2x)','cos(3x)','cos(4x)'},'Location','northwest','NumColumns',2)
@Luna, Thank you very much.

Sign in to comment.

More Answers (2)

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:
plot(t_obs,car_data,'.','markersize',18)
Or take a look at some examples with bar-graphs...
HTH

4 Comments

Hi, i meant about physical apperance. Thank you for the suggestion
Yes. I understood that. There are things you should allow yourself to do when presenting your data and things not to do. Chosing other type of plots, like stacked bar-graphs, stair-plots etc are absolutely OK, smoothing your type of data - not so much. If you plot only the data-points as points instead of connecting them with line-segments you let the viewers smooth their data in their eyes - that's what they will do more or less automatically.
I think bar graph or histogram is not suitable because he wants to see the data change in time.
What? Bar graphs can do that:
bar(t,car_locations,1,'stacked','edgecolor','none')

Sign in to comment.

atharva aalok
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)
Sample Plot:
Color Palatte:

Categories

Tags

Asked:

on 14 Feb 2019

Edited:

on 17 Oct 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!