Split Y axis into two with different colors

조회 수: 5 (최근 30일)
Guilherme Salome
Guilherme Salome 2017년 8월 30일
편집: Guilherme Salome 2017년 8월 30일
I am trying to plot two sequences of bars, using the same y-axis. One of the sequences goes on the bottom, the other goes on top (from top to bottom), and the y axis is split into two (half for the bottom bars and half for the top bars). The bottom bars use one color, like green, and the top bars use another color, red, and the y axis uses the respective colors on each half on the axis.
Example:
I have absolutely no idea how to split the y-axis in this way. Could someone please help me?
Thanks for helping! =D

채택된 답변

Guilherme Salome
Guilherme Salome 2017년 8월 30일
편집: Guilherme Salome 2017년 8월 30일
Full Solution here:

추가 답변 (1개)

Jan
Jan 2017년 8월 30일
편집: Jan 2017년 8월 30일
Do you mean something like this:
x = rand(1, 8);
axes2 = axes('NextPlot', 'add', 'Visible', 'on', 'YDir', 'normal', 'YLim', [0, 2]);
bar(x, 'g');
axes2 = axes('NextPlot', 'add', 'Visible', 'off', 'YDir', 'reverse', 'YLim', [0, 2]);
bar(x, 'r');
Or does the question concern the tick marks? This can be included also.

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by