Scatter Plot with multiple 'levels' on the Xaxis

8 visualizaciones (últimos 30 días)
Bharat N
Bharat N el 11 de Feb. de 2021
Comentada: Adam Danz el 15 de Feb. de 2021
Hello Everyone,
I am trying to make a relatively complex plot.
Can the community please help me - I would like to have multiple 'levels' of X axis?
To explain myself better, below is the desired result (image) and attached is the example data (with constrains noted in the excel)....
Thank you.
Bharat

Respuestas (1)

Adam Danz
Adam Danz el 11 de Feb. de 2021
Editada: Adam Danz el 11 de Feb. de 2021
I see two options.
1. Since the "test" and country labels are vertically stacked, you could set multiple rows of x-tick labels for those labels and single rows for the other tick labels, all in the same line of code.
ticks = {'1' 'Test' '10' '1' 'Test' '10' '1' 'Test' '10' '1' 'Test' '10'; ...
'' 'USA' '' '' 'Mexico' '' '' 'Canada', '' 'Peru' ''};
2. You can use text() to add the country labels, following option #3 in the same answer.
  2 comentarios
Bharat N
Bharat N el 14 de Feb. de 2021
Thanks @Adam Danz for the super quick feedback.
I tried it out for my actual dataset, but for aesthetic reasons, I went with 'nexttile' and completely separated the plots...
Thank you !!
Adam Danz
Adam Danz el 15 de Feb. de 2021
If you want the axes to be bordering each other, you can achieve that by setting axes directly with axes().

Iniciar sesión para comentar.

Categorías

Más información sobre Scatter 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