Custom Plot with matlab

2 visualizaciones (últimos 30 días)
Emin BAKIR
Emin BAKIR el 9 de Mayo de 2016
Respondida: Emin BAKIR el 14 de Mayo de 2016
I need to draw a custom plot with in Matlab, actually I will combine 4 different graph in one, with the following scenario Let say, I run an application for 4 times, the values goes to X axis will always be same, so for each run, x1=x2=x3=x4=[1 2 3 4];
For every x point there will be a y point, an element of set A=('a','b','c'),
Let say for each run the corresponding Y values are: y 1=['a' 'b' 'a' 'c']; y2=['a' 'a' 'b' 'c']; y3=['c' 'a' 'a' 'a']; and y4=['a' 'b' 'c' 'a']; with these values I want to draw a figure which combines all 4 runs in one chart. I want to represent the Y values as a 1 unit tall (actually its height is not that much matter) coloured vertical line, instead of just points. The following image demonstrated the figure I want to draw, anyone knows a way to achieve this? Thanks

Respuesta aceptada

KSSV
KSSV el 10 de Mayo de 2016
clc; clear all ;
% Set colors
a = 'g' ; b = 'r' ; c = 'y' ;
c1 = [{a} {b} {a} {c}] ;
c2 = [{a} {b} {b} {c}] ;
c3 = [{c} {a} {a} {a}] ;
c4 = [{a} {b} {c} {a}] ;
c = [c1 ; c2 ; c3; c4] ;
% Make grid
x = linspace(0,1,5) ;
y = linspace(0,1,5) ;
[X,Y] = meshgrid(x,y) ;
% Plot
figure
pcolor(X,Y,NaN(size(X)))
hold on
for i = 1:4
for j = 1:4
plot([X(i,j),X(i+1,j)],[Y(i,j),Y(i+1,j)],c{i,j},'linewidth',5)
end
end
axis off
xlim([x(1) x(end-1)])

Más respuestas (1)

Emin BAKIR
Emin BAKIR el 14 de Mayo de 2016
Thank you Siva, It helped. Cheers

Categorías

Más información sobre Line Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by