Useful Gibberish

Posts tagged ‘plot’

Purify excel/gnumeric sheetdata

When extract data from a simulation, maybe sometimes we have too much data and we don’t really need all data point, so these questions may pop out:

  • How to make data less?

  • How to plot every 5 data point.

Let me explain, for example we have (x,y) data in column A and B, each column has 1000 data point and we want to plot/mahe chart for only 1st,5th,10th data point, so here is what we need to do:

  • In column C, input this function
    =mod(row(A1),5)

    The function row() will return the number of the line that the cell belong to, so in A1, row A1 will return 1.
    The function mod() will return the modulus of, for in stance mod(5,2), 5 divide by 2, is 3.
    So the function mentioned above will return from top to bottom the sequence 0,1,2,3,4,0,1…..

Now create an auto filter of that data, and criteria should be the column C, if you want to plot only the line 2, choose it 2 for example.
That’s it. Pretty easy. I’ll find a way to plot in Matlab too.

Update: For matlab it very easy.
For example we have x and y as the arrays. And we want ot plot only every 5 pairs of the data set.
We do like this:

x1=x[1:5:end];
y1=y[1:5:end];
plot(x1,y1)

Useful MatLab code for plotting

Increase all text size:
set(gca,'FontSize',14)
figureHandle = gcf;
set(findall(figureHandle,'type','text'),'fontSize',14)

Labelling the plot:
xlabel('$\alpha_\varepsilon$ - direction of strain probe $(\circ)$','interpreter','latex');
ylabel('Second order work $W_2$ and $W_2^{\mu}$ (J)','interpreter','latex');

Hatch region:
harea = area([140 140 150 150 140],[-0.05 0.3 0.3 -0.05 -0.05],3 );
child=get(harea,'Children')
set( harea, 'FaceColor', 'm')
alpha('texture')

Increase text size for plotyy function

[ax h1 h2]=plotyy(e22,ev,e22,q)
set(ax,'FontSize',14)

Subplot

%subplot of (w2 normalized), (compare), (new,lostcontact), (total contact)
subplot(2,2,1);
polar(degtorad(alpha),w2normal,'r--*');
title('Normalized $W_2$ at $\eta=0.92$','interpreter','latex')

subplot(2,2,2);
plot(alpha,ntotal,'b--*');
xlim([0 350]);
xlabel('Angle of stress probe - $\alpha_\sigma$','interpreter','latex');
ylabel('Total contacts - $N_c$','interpreter','latex');
grid on;
title('Total contacts numbers $N_c$ at $\alpha_\sigma$','interpreter','latex')

subplot(2,2,3);
plot(alpha,nlost,'r--o',alpha,nnew,'b--*');
xlim([0 350]);
xlabel('Angle of stress probe - $\alpha_\sigma$','interpreter','latex');
ylabel('New ($N_{new}$) and lost ($N_{lost}$) contacts','interpreter','latex');
legend('N_{lost}','N_{New}');
grid on;
title('Lost contacts and new contacts during the directional research')

subplot(2,2,4);
plot(alpha,w2macro,'b--o',alpha,w2micro,'r--*');
legend('W_2 macro','W_2 micro');
xlabel('Angle of stress probe - $\alpha_\sigma$','interpreter','latex');
ylabel('Second order work (J)','interpreter','latex');
xlim([0 350]);
grid on;
title('Comparison $W_{2}macro$ and $W_{2}micro$','interpreter','latex')

Tag Cloud

%d bloggers like this: