xlim in boxchart not working

15 visualizaciones (últimos 30 días)
Marwa Tuffaha
Marwa Tuffaha el 1 de Nov. de 2023
Comentada: Star Strider el 2 de Nov. de 2023
How can I change the X-axis limits in a boxchart? I want to cut the extra space on the left of "C>A" and right of "T>G" but I am not sure how to do so.
When I write:
xlim([0.5 3.5])
Matlab says: "Error using xlim
Value must be a 2-element vector of increasing or equal categorical values as ordered by the ruler Categories property."
Please note that I have imitated the "TemperatureData.csv" example in this webpage to plot this figure.
The problem I mentioned above comes somehow from the boxchart command; xlim works on boxplot properly. So, if you have a method to plot two distributions for each category in different colors using boxplot, the problem might be solved.

Respuesta aceptada

Star Strider
Star Strider el 1 de Nov. de 2023
It would help to have the data and code to test, since I cannot find any examples in the boxchart documentation that could provide a similar plot.
That aside, if you are using categorical variables for the x-axis, numeric values for xlim may not work. It may be necessary to use numeric values for the xticks and then use separate xticklabels to label them. (The only relevant experience I have with this is with bar plots, that need to have numeric x-axis coordinates if such as error bars or bar labes are added to them. This does not work with categorical variables, so the usual approach is to use numeric x-variables and then label them using xticklabels.)
  2 comentarios
Marwa Tuffaha
Marwa Tuffaha el 2 de Nov. de 2023
Sorry I couldn't share the data as it is part of a research project and not shareable at this point. However, your hint helped me solve the problem.. Thanks!
Star Strider
Star Strider el 2 de Nov. de 2023
As always, my pleasure!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Get Started with Curve Fitting Toolbox en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by