Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8550959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:05:12+00:00 2026-06-11T14:05:12+00:00

I want to create a vertical bar plot. This is my code: bar (x,

  • 0

I want to create a vertical bar plot. This is my code:

bar (x, sensiv);
title ('Promedio X')
xlabel('Nm')
ylabel('Refl.')

The problem is it looks like a stair plot. I’ve tried to add (x,sensiv, ‘stacked’) but it doesn’t work. It looks grouped, as you can see in the next image:

graph http://imageshack.us/a/img689/9449/capturawv.jpg

I think it’s because of x-axis but I couldn’t change it. How can I do it? Does somebody knows how can I do it?

EDIT

Thanks Colin! I’ve tried to zoom and I understand what you mean and I’ve tried with different values, as slayton and you said.

Graph with value 0.000001
Graph with value 1
I think that maybe it’s the way I’ve code the plot, it is possible?

abc=0;
for p=(61:201)
    abc(p)=out1_c;
end
for p=(151:301)
    abc(p)=out2_c;
end
for p=(231:380)
    abc(p)=out3_c;
end
for p=(381:596)
    abc(p)=out4_c;
end
for p=(1152:1531)
    abc(p)=out5_c;
end
for p=(1651:2051)
    abc(p)=out7_c;
end
for p=(2052:2151)
    abc(p)= 0;
end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T14:05:13+00:00Added an answer on June 11, 2026 at 2:05 pm

    The default value for the width of the bars in a bar plot is 0.8, so given that you’re not currently specifying the width, you should have gaps in between each bar. This is going to sound really obvious, but have you tried zooming in on the bar plot that is created? For some datasets, the bar function will return a plot that looks like a stair plot, but in fact has gaps if you zoom in far enough. If this is the case, then you should be able to get the gaps you want by tinkering with the width parameter as suggested by slayton.

    EDIT

    Okay. First things first. If you want to post additional information, you should add it to your question, NOT post it as a new answer! You can do this by clicking the edit button just below where your question is on the page. To make things more readable, you might preface your edit with a capitalized bold-face heading “EDIT” as I have done here. If you are able, try now to move the additional information you’ve given back into your question, and then delete the answer.

    Second, I have to be honest, the additional information you posted was somewhat confusing. However, I think I understand what you want now. You want 7 bars coming up to the heights out1_c, out2_c, …, out7_c (variable names taken from your additional information) with a small gap between each bar, and the x-axis to reflect (approximately) the intervals 450-550, 550-650, etc.

    Well, if you want 7 bars, then you want your input to only have seven elements. Set:

    y = [out1_c; out2_c; out3_c; out4_c; out5_c; out6_c; out7_c];
    

    y now gives you the heights your bars will come up to on the y-axis. To locate the bars on the x-axis, define a vector x that also has seven elements, where each element gives the midpoint of where you want the bar to be on the x-axis. For example:

    x = [100; 200; 300; 400; 500; 600; 700];
    

    Then just use bar(x, y). This should get you started.

    A final point on the code you posted, you can actually completely avoid the loops: read up on vectorization. But if you are going to insist on loops, the first and most important rule is to preallocate your vectors/matrices. In your code abc starts out as a scalar (a 1 by 1 matrix), but then for every p, you are adding an element at index p. What is actually happening in the background is for every p, matlab is scrapping the current abc you have in memory, and building it again from scratch with the additional element. As you might expect, this will slow down your code by many orders of magnitude.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create a vertical line shadow over the whole page like this:
i want create Dynamic Slideshow in Jquery i'm Write this code var ctx =
I want to create a bar with different widgets like this .. Instead of
I wonder, is it possible to create vertical marker in zedgraph ? I want
I want to create a horizontal and vertical accordion in asp.net. I have use
I want to create an Application with tabs, and I have found this guide
I want to create a layout like below.. This is the XML i have
i want to create vertical expandable list view using java script.like here click .If
I'm trying to create a vertical button in PHP, but I have problem with
I want to create a TextView that does NOT wrap text, and allow vertical/horizontal

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.