이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
Hi,
I intend to do a chart with two yaxis, the code is the following:
dates=datenum(dataSet(:,1));
%SPX
SPX=dataSet(:,2);
%VIX
VIX=dataSet(:,3);
plotyy(dates,SPX,dates,VIX);
%datevc divides the date in different columns, first colum is the year,
%second the month and thrid the day
d=datevec(dates);
%Takes just the year (first column)
d=d(:,1);
%takes every year just once
[a,idx]=unique(d(:,1),'first');
ylabel('VIX');
set(gca,'xtick',dates(idx),'xticklabel',a)
ytix = get(gca,'YTick');
set(gca,'YTick',ytix(2:end));
This is working but unfortunately besides the years I have also the numeric date displayed on the x axis, how can I change that?
is there a way to make both y axis black instead of blue and green?
채택된 답변
Azzi Abdelmalek
2013년 5월 2일
use
[ax,h1,h2]=plotyy(dates,SPX,dates,VIX);
set(ax(1),'ycolor','k')
set(ax(2),'ycolor','k')
댓글 수: 11
Locks
2013년 5월 2일
thanks, this has solved the color issue, do you have a solution to see only the dates on the xaxis and not the numerical value?
use
set(ax,'xtick',dates(idx),'xticklabel',a)
that works as well, thanks
the last thing that is missing now is that both time series start at the left and right yaxis (so that there are no spaces between the y axis and the time series)
is there something similar to this:
axis([xmin xmax ymin ymax]) when there are two y axis?
set(ax(1),'ylim',[min(y1) max(y1)]) %y1 your first signal
set(ax(2),'ylim',[min(y2) max(y2)]) %y2 your second signal
Locks
2013년 5월 2일
that's working perfectly. I tried in addition to get a value for every step of 200 using this:
set(ax(1),'ylim',[0:200:2000]) set(ax(2),'ylim',[0:20:100])
but that does not work, is there something else I can do?
In addition, there is still a space between the y axis and the times series, I tried this:
axis tight
but that does only work for one of the series and the left y axis, but not for both
It should be
set(ax(1),'ylim',[0 2000])
set(ax(2),'ylim',[0 100])
Locks
2013년 5월 2일
yes, this is fine but this one only values displayed on the left yaxis are 0 1000 and 2000 and I would like to have a scale in steps of 200
the same goes for the right y axis
do you have a solution for the second problem as well?
set(ax(1),'ytick',[0:200:2000])
set(ax(2),'ytick',[0:20:100])
Locks
2013년 5월 2일
perfect, thanks!!
Have you also a solution that there are no spaces between the plot and the y axis, in other words the plot should start at the left yaxis and ends at the richt yaxis
set(ax,'xlim',[min(x) max(x)])
Locks
2013년 5월 2일
perfect, thanks
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Dates and Time에 대해 자세히 알아보기
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
