How can I include a superscript in my x-label

22 views (last 30 days)
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 Comments
Anthony Arteaga
Anthony Arteaga on 15 Aug 2019
No its just extra information I added. I just need help with my x-axis labeling.
Adam Danz
Adam Danz on 15 Aug 2019
Edited: Adam Danz on 15 Aug 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.

Sign in to comment.

Answers (1)

Star Strider
Star Strider on 15 Aug 2019
Edited: Star Strider on 15 Aug 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.

Community Treasure Hunt

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

Start Hunting!