How do I reduce my right y axis scale ?

28 visualizaciones (últimos 30 días)
Pierre Lonfat
Pierre Lonfat el 2 de Mzo. de 2018
Comentada: Greg el 30 de Abr. de 2018
Here is the actual result.
Where you can see the bar chart in green overlapping the curves which is not really nice.
The idea would be to have something like that:
Now the scale is reduce but I have unnecessary number in the right y axis and missing numbers [2 1.5 1 0.5 0].
Can someone help me with that ?
Thank you very much in advance.
Pierre
  2 comentarios
Pierre Lonfat
Pierre Lonfat el 2 de Mzo. de 2018
Editada: dpb el 14 de Mzo. de 2018
My actual code:
f = figure;
set(gca,'FontName','Times New Roman');
yyaxis right
bar(riskpremium.date.raw(1:end,1),riskpremium.decision_action(1:end,1),'FaceColor',[0.5 1 0.5],'LineWidth',1);
hold on
plot(riskpremium.date.raw(1:end,1),ones(length(riskpremium.date.raw))*riskpremium.weights(1,1),'--','MarkerSize',15,...
'Color','k','LineWidth',0.2);
hold on;
plot(riskpremium.date.raw(1:end,1),ones(length(riskpremium.date.raw))*riskpremium.weights(2,1),'--','MarkerSize',15,...
'Color','k','LineWidth',0.2);
hold on;
plot(riskpremium.date.raw(1:end,1),ones(length(riskpremium.date.raw))*riskpremium.weights(3,1),'--','MarkerSize',15,...
'Color','k','LineWidth',0.2);
hold on;
plot(riskpremium.date.raw(1:end,1),ones(length(riskpremium.date.raw))*riskpremium.weights(4,1),'--','MarkerSize',15,...
'Color','k','LineWidth',0.2);
hold on;
plot(riskpremium.date.raw(1:end,1),ones(length(riskpremium.date.raw))*riskpremium.weights(5,1),'--','MarkerSize',15,...
'Color','k','LineWidth',0.2);
hold on;
ylabel('Decision weights - Barometer','FontSize',12);
ylim([0.5 10])
dpb
dpb el 13 de Mzo. de 2018
Editada: dpb el 14 de Mzo. de 2018
Attach the data so somebody can play around without having to try to make up data that looks similar-enough.
The obvious (I think) would be when you use yyaxis to place one on the RH and another on the LH axes.
In the sequence
My actual code:
bar(riskpremium.date.raw(1:end,1), ...
hold on
plot(riskpremium.date.raw(1:end,1), ...
hold on;
plot(riskpremium.date.raw(1:end,1), ...
hold on;
...
once 'hold' is 'on', it won't get in "onner" by repeating it...once is enough on the given axis.

Iniciar sesión para comentar.

Respuesta aceptada

Greg
Greg el 14 de Mzo. de 2018
yyaxis('right');
ylim([0,10]); % Play with 10 until it looks good
yticks(0:.5:2);
  2 comentarios
Pierre Lonfat
Pierre Lonfat el 30 de Abr. de 2018
Love you !
Greg
Greg el 30 de Abr. de 2018
Happy to help.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by