I have to plot a graph where +1 and -1 are located at same point on x axis. How can I do that?

13 ビュー (過去 30 日間)
I want the scale on X axis to be like this
and the values of x,y are as follows (-0.6,0.9) (-0.7,0.8) (-.95,0.6) (0.6,0.5) (0.7,0.4) (1,0.3) (0.8,0.4) (0.6,0.5)(0,0.5)(-0.6,0.6) (-0.7,0.8) (-0.6,0.9)
  2 件のコメント
Image Analyst
Image Analyst 2014 年 6 月 9 日
That seems like a very deceptive and misleading way to set up your x-axis that's sure to confuse whomever you want to show it to. Why do you want to do that?
anoohya
anoohya 2014 年 6 月 9 日
編集済み: anoohya 2014 年 6 月 9 日
I was actually told to do it that way. This is a part of research project where they want to represent the power factor on x axis. Is there any way that i could do it? I tried doing it in excel but i'm facing many problems and m not able to get what i want at the end.
Everything else is easy in matlab except that im stuck with this. Is there any way to get this?

サインインしてコメントする。

採用された回答

A Jenkins
A Jenkins 2014 年 6 月 9 日
Here is how I would do it. Your proposed tick values don't work perfectly with your data, but you can adjust it.
% given data
data_values = [ -0.6,0.9; -0.7,0.8; -.95,0.6; 0.6,0.5; 0.7,0.4; ...
1,0.3; 0.8,0.4; 0.6,0.5; 0,0.5; -0.6,0.6; -0.7,0.8; -0.6,0.9];
% put your desired ticks here
xticklables=[-.6,-.65,-.7,-.75,-.8,-.85,-.9,-.95,1,.95,.9,.85,.80];
% transform ticks to new scale
xtick=-xticklables;
idx=xtick<0;
xtick(idx)=xtick(idx)+2;
% transform the data to the new scale
data_values(:,1)=-data_values(:,1);
idx=data_values(:,1)<0;
data_values(idx)=data_values(idx)+2;
% plot and adjust labels
scatter(data_values(:,1), data_values(:,2));
xlim([min(xtick), max(xtick)]);
set(gca,'xtick',xtick);
set(gca,'xticklabel',xticklables);
  2 件のコメント
anoohya
anoohya 2014 年 6 月 9 日
That helped. Thanks a lot. Is there any way that i could join the points in the order they're written? I don't think that can be done using a scatter plot. Is there any other alternative?
A Jenkins
A Jenkins 2014 年 6 月 10 日
Just replace scatter() with plot(). Or try any of the other plotting functions .

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeScatter Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by