Label log axes with superscript notation?

  • Thread starter Thread starter Henry Fleming
  • Start date Start date
H

Henry Fleming

Hello

I am using VB to create a chart with log base 10 axis with a range of
0.1 to 100000. The major ticks are labelled with the number value.
However, I need a scientific-quality chart that uses "10 to the power
of x" notation with x being a superscript. Excel's option of using
1.00E-1, 1.00E+0, etc. is not acceptable in my case. Does anyone know
how to achieve this? I cannot believe Microsoft would not include
this option as it is standard style in scientific charts.
 
Hi Henry,

Don't think there is a standard way of doing it BUT you can do it using
a dummy data series and a little routine I wrote for a previous and
similar request.

Use a dummy series to mimic the axis.
If you link the datalabels to cells you will not be able to use
superscript. So you will have to set the text explicitly.
The routine below will create the text and format the power value to
superscript.

Also take a look at Jon Peltier's site on how to create your own axis;
(http://www.geocities.com/jonpeltier/Excel/Charts/ArbitraryAxis.html)

Sub MakeSuperScript()
Dim intIndex As Integer
Dim strPower As String

' Adjust SeriesCollection(2) so it uses your dummy series
With ActiveChart.SeriesCollection(2)
.HasDataLabels = True
.DataLabels.Position = xlLabelPositionBelow
For intIndex = 1 To .DataLabels.Count
strPower = CStr(intIndex - 1)
.DataLabels(intIndex).Text = "10" & strPower
.DataLabels(intIndex).Characters(3,
Len(strPower)).Font.Superscript = True
Next
End With
End Sub


Henry said:
Hello

I am using VB to create a chart with log base 10 axis with a range of
0.1 to 100000. The major ticks are labelled with the number value.
However, I need a scientific-quality chart that uses "10 to the power
of x" notation with x being a superscript. Excel's option of using
1.00E-1, 1.00E+0, etc. is not acceptable in my case. Does anyone know
how to achieve this? I cannot believe Microsoft would not include
this option as it is standard style in scientific charts.

--

Cheers
Andy

http://www.andypope.info
 
Great! This works. Thanks!


Andy Pope said:
Hi Henry,

Don't think there is a standard way of doing it BUT you can do it using
a dummy data series and a little routine I wrote for a previous and
similar request.

Use a dummy series to mimic the axis.
If you link the datalabels to cells you will not be able to use
superscript. So you will have to set the text explicitly.
The routine below will create the text and format the power value to
superscript.

Also take a look at Jon Peltier's site on how to create your own axis;
(http://www.geocities.com/jonpeltier/Excel/Charts/ArbitraryAxis.html)

Sub MakeSuperScript()
Dim intIndex As Integer
Dim strPower As String

' Adjust SeriesCollection(2) so it uses your dummy series
With ActiveChart.SeriesCollection(2)
.HasDataLabels = True
.DataLabels.Position = xlLabelPositionBelow
For intIndex = 1 To .DataLabels.Count
strPower = CStr(intIndex - 1)
.DataLabels(intIndex).Text = "10" & strPower
.DataLabels(intIndex).Characters(3,
Len(strPower)).Font.Superscript = True
Next
End With
End Sub
 
Back
Top