How can I include a superscript in my x-label

I'm having a problem with labeling my x-axis with powers of 10. For example, I have 8 sample collections with concentrations ranging from 10^-3 - 10^-9.

5 commentaires

Adam Danz
Adam Danz le 15 Août 2019
How are you creating your plot? You can manipulate the notation in most of the plots but we need more detail. What kind of tick marks would you like?
Anthony Arteaga
Anthony Arteaga le 15 Août 2019
x=0:10^-3:10^-4:10^-5:10^-6:10^-7:10^-8:10^-9;
y=[3198.8 2222.8 2798.8 2728.8 3671 4408.5 4303.5 4485.3];
bar(x,y)
This is what I have. Sorry if it sucks I'm brand new to MATLAB.
I get this error message:
Error using bar (line 172)
X must be same length as Y.
Error in bargraph (line 3)
bar(x,y)
Adam Danz
Adam Danz le 15 Août 2019
Is this your question (about the error message) or is this a different question that your original one above?
Anthony Arteaga
Anthony Arteaga le 15 Août 2019
No its just extra information I added. I just need help with my x-axis labeling.
Adam Danz
Adam Danz le 15 Août 2019
Modifié(e) : Adam Danz le 15 Août 2019
This: x=0:10^-3:10^-4:10^-5:10^-6:10^-7:10^-8:10^-9;
is not anything meaningful. It results in x=0.
Is this more like what you're looking for (I doubt it)?
x=[0, 10^-3, 10^-4, 10^-5, 10^-6, 10^-7, 10^-8, 10^-9];
y=[3198.8 2222.8 2798.8 2728.8 3671 4408.5 4303.5 4485.3];
bar(x,y)
ax = gca();
ax.XScale = 'log'
"I just need help with my x-axis labeling. "
You haven't explained what you need help with - what's wrong with the labels? How would you like to change them? By "labels" I think you mean X-Tick labels.

Connectez-vous pour commenter.

Réponses (1)

Star Strider
Star Strider le 15 Août 2019
Modifié(e) : Star Strider le 15 Août 2019
The easiest approach is likely to use semilogx (or if appropriate, loglog) to plot your data.
EDIT —
I am not sure what tick labels you want.
Try this:
y=[3198.8 2222.8 2798.8 2728.8 3671 4408.5 4303.5 4485.3];
figure
bar(y)
Ax = gca;
xlbl = sprintfc('10^{%2d}', -(3:9));
Ax.XTickLabel = [{'0'} xlbl];
Ax.FontSize = 9;
How can I include a superscript in my x-label - 2019 08 15.png
The tick labels can easily be changed when I understand what you want them to be.

Catégories

En savoir plus sur Labels and Annotations dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by