Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make 1-D plots in MATLAB?

Tags:

plot

matlab

How can I make plots in MATLAB like in below? 1D plot example

I won't need labels, so you can ignore them. I tried using normal 2D plot, by giving 0 to y parameter for each data points. It does help, but most of the plot remains empty/white and I don't want that. 1d plot in 2d figure

How can I solve this problem?

Edit:

This is how I plot(playing with values of ylim does not help):

hold on
for i=1:120
    if genders(v_labels(i)) == CLASS_WOMAN
        plot(v_images_lda(i,:) * w_lda,0,'r*');
    else
        plot(v_images_lda(i,:) * w_lda,0,'b.');
    end
end
title('LDA 1D Plot');
ylim([-0.2 0.2]);
hold off
like image 271
kolistivra Avatar asked Apr 21 '11 16:04

kolistivra


People also ask

How do you plot a discrete value?

Visualize discrete data using plots such as bar graphs or stem plots. For example, you can create a vertical or horizontal bar graph where the bar lengths are proportional to the values that they represent.

How do you plot multiple figures in MATLAB?

To create a plot that spans multiple rows or columns, specify the span argument when you call nexttile . For example, create a 2-by-2 layout. Plot into the first two tiles. Then create a plot that spans one row and two columns.


1 Answers

One way to do this would be to adjust the 'XLim', 'YLim', and 'DataAspectRatio' properties of the axes so that it renders as essentially a single line. Here's an example:

data1 = rand(1,20)./2;      %# Sample data set 1
data2 = 0.3+rand(1,20)./2;  %# Sample data set 2
hAxes = axes('NextPlot','add',...           %# Add subsequent plots to the axes,
             'DataAspectRatio',[1 1 1],...  %#   match the scaling of each axis,
             'XLim',[0 1],...               %#   set the x axis limit,
             'YLim',[0 eps],...             %#   set the y axis limit (tiny!),
             'Color','none');               %#   and don't use a background color
plot(data1,0,'r*','MarkerSize',10);  %# Plot data set 1
plot(data2,0,'b.','MarkerSize',10);  %# Plot data set 2

And you will get the following plot:

enter image description here

like image 159
gnovice Avatar answered Oct 06 '22 08:10

gnovice