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 件のコメント

Luna
Luna 2019 年 2 月 14 日
Could you please attach your data? And also what do you mean by look beautiful? Data manipulation or physical appereance like color, linewidth,etc?..
Hari krishnan
Hari krishnan 2019 年 2 月 14 日
The data size is very large. I am not able to attach the data after compressing the file too. I mean physical appearance.
madhan ravi
madhan ravi 2019 年 2 月 14 日
Use interp1() with 'spline' method if your only concerned about appearance.
Bjorn Gustavsson
Bjorn Gustavsson 2019 年 2 月 14 日
Why use interp1? Only to produce graphs implying fractions of vehicles are out in traffic?
madhan ravi
madhan ravi 2019 年 2 月 14 日
編集済み: madhan ravi 2019 年 2 月 14 日
I meant if OP is concerned about appearance!
Bjorn Gustavsson
Bjorn Gustavsson 2019 年 2 月 15 日
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.

サインインしてコメントする。

 採用された回答

Luna
Luna 2019 年 2 月 14 日
編集済み: Luna 2019 年 2 月 14 日

2 投票

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 件のコメント

Hari krishnan
Hari krishnan 2019 年 2 月 14 日
@Luna, thank you very much for the help with detailed description.
Luna
Luna 2019 年 2 月 14 日
Your welcome :)
Hari krishnan
Hari krishnan 2019 年 2 月 14 日
@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')
Luna
Luna 2019 年 2 月 14 日
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)
Hari krishnan
Hari krishnan 2019 年 2 月 17 日
@Luna, Thank you very much.

サインインしてコメントする。

その他の回答 (2 件)

Bjorn Gustavsson
Bjorn Gustavsson 2019 年 2 月 14 日

1 投票

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 件のコメント

Hari krishnan
Hari krishnan 2019 年 2 月 14 日
Hi, i meant about physical apperance. Thank you for the suggestion
Bjorn Gustavsson
Bjorn Gustavsson 2019 年 2 月 14 日
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.
Luna
Luna 2019 年 2 月 14 日
I think bar graph or histogram is not suitable because he wants to see the data change in time.
Bjorn Gustavsson
Bjorn Gustavsson 2019 年 2 月 15 日
What? Bar graphs can do that:
bar(t,car_locations,1,'stacked','edgecolor','none')

サインインしてコメントする。

atharva aalok
atharva aalok 2021 年 10 月 17 日
編集済み: atharva aalok 2021 年 10 月 17 日

0 投票

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:

カテゴリ

ヘルプ センター および File ExchangeDiscrete Data Plots についてさらに検索

タグ

質問済み:

2019 年 2 月 14 日

編集済み:

2021 年 10 月 17 日

Community Treasure Hunt

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

Start Hunting!

Translated by