Clear Filters
Clear Filters

How do we plot the graph with non available values in x axis.

8 views (last 30 days)
I am having an array
2-10
3--
4-20
5--
6-30
7--
8-40
When i plot the graph by using the command
set(gca,'Xdir','reverse','xtick',(8:2:2),'xlim',[2 8]);
plot(set,'-ys')
I am getting the graph with square in 8,6,4,2,as it has values.how to get the square in intermediate places 7,5,3 which has no values.

Answers (1)

dpb
dpb on 31 Oct 2018
Edited: dpb on 31 Oct 2018
There's no way the code posted will do what you say; it has fatal syntax error both lines--in the first the 'XTick' vector must be specified as (2:2:8) as it is required for tick values to be increasing when set irregardless of the sense of the direction named parameter; it does the reversal internally. As written (8:2:2) it's a silent error but turns the ticks off because with a positive increment but the end value less than start, it returns an empty array.
plot(set,'-ys')
fails because there's no argument to the set function.
As to the original question, you'll have to interpolate or otherwise find and plot values for the other X locations to place a square there or it would be possible with some additional effort to use text or annotation to add the markers where wanted independently of the plotted data.

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!