简体   繁体   中英

How to do an Arrhenius plot using excel-VBA? AKA: How to do a reciprocal x-axis in excel-VBA?

I want to write a program to transform temperature dependend data into an Arrhenius plot. An Arrhenius plot show the logarithm of a property that is thermally acitavted versus the reciprocal temperature aka 1/T. Now is 1/T something that most people are not used to. This is why most of the plot also contain the translation in temperature on a second axis. Usually on top of the graph. The output should look like this:

在此处输入图片说明

Picture Source

The second axis is only for better readability and is corresponds to the primary axis with the relation:

primary=1/secondary 

secondary=1/primary

What I am not able to do in excel-VBA (excel 2010) is the reciprocal second x-axis. There is no predefined axis scaling like this. There is xlScaleLinear and xlScaleLogarithmic for the property ScaleType of an axis. Is there a way to do this?

A secondary problem is that this:

Dim CH As Chart

Set CH = Tabelle2.ChartObjects(1).Chart

CH.ChartType = xlXYScatterLinesNoMarkers

With CH
    .HasAxis(xlCategory, xlSecondary) = True
End With

Does not seem to work. Which means that a xyScatterplot does not seem to have a secondaryXaxis enabled.

I could try to add the lables and ticks myself using forms but this seems a little to much pain, I cannot be the only one who has encountered this problem.

  • Problem 1: How to format an axis reciprocal (1/x)?

  • Problem 1b: How to properly add a second x axis in a XYscatterplot?

You can do this by creating a fake axis using a series with data labels (inspired by https://peltiertech.com/secondary-axes-that-work-proportional-scales/ ):

在此处输入图片说明

Columns A and B are your data. Column C matches the X-ticks of your primary X-axis. Column D is =1/C2 etc and column E is the y-axis maximum for your chart. Now simply create a new series of columns C and E, format it to have no line and in this case I chose the + marker but you can create your own vertical line marker if you want it to be exact. Then add data labels set to range column D.

I don't think you'll find another way to do it without this hack, but it's really not that hard and doesn't require VBA which is always a plus in terms of readability / audibility of your workbook.

Another alternative would be to use the data labels to write the actual temperature to the data points:

在此处输入图片说明

Column C has the temperature in Celsius.

Since the Arrhenius plot is only defined as ln(k) against 1/T , this would be a good option I think.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM