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

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.

Related

charting trendlines together

I need to display this kind of data in one chart:
Which means:
Function A: Y= X + 10 ;
Function B: Y= X * 2 ;
but what I got from excel is:
Actually what I want is (sorry for the drawing):
My real data is like:
If I format it like this:
I can still not get the correct charts.
Updated to account for change of question
Your data structure is wrong to achieve this in Excel, see for example:
On the left you want your x axis values, don't put a header in this column otherwise it will plotted on your graph as a series (extra line).
You can fill in gaps in your data with #N/A and excel will ignore these points, joining the line to the next available point.

Excel scatter plot

Hello and good day to all
I have question related to excel graph. I have some set of values like this
Now I want to plot these values as a scatter graph. I want to to draw in such a way that by keeping X values same and 4 different Y plots i.e. A, B, C, D in a single graph. Meaning I dont want to merge these Y values on a single X value. Is there any way to do that? I thank you for your time and help.
The data does not make much sense. All X values are exactly the same, so all data markers will be at exactly the same X position.
To create a scatter chart with multiple series:
- select the data from A1 to B11
- insert a scatter chart
- select the B, C, D ranges (C1 to E11) and copy
- select the chart and use Paste Special > insert as new series with series name in first row
Since all X values are the same, many data points overlap and are not distinguishable.
Edit after comment: if you do NOT want to plot the values at their true X position (i.e. the value 1.4), then use four pairs of X / Y coordinates. Use X values 1 to 4 with A to D. Then use text boxes to replace the X axis labels or hide the labels and show the legend instead.

Scatter plot for variable number of rows and specific columns

I want to create an automated scatter plot. This is the first example table based on the step size I end up measuring A, B, C, D for a specific frequency. In this scatter plot I created manually you can see I want to plot C v/s A for a particular frequency.
But I need to do this automatically as based on the step size the number of row can change. Here, since the step size decreased the number of samples increased, and now the scatter plot needs to update number of A and C values it plots.
Is there a formula I can use without using any macros?
The relation between the step size and frequency is (number of samples of a single frequency = (360/step size)) so for a step size of 60 you will have in reality six entries of frequency 100 and six of 200 .
You can use formulas to define chart ranges if you hide the formulas in named ranges. Combine that with the fact that #N/A values are not plotted and you can get this to work without VBA.
For your example graph you could define two names ranges as follows:
Name: A_100
Refers To: =IF(Sheet1!$E$3:$E$100=100,OFFSET(Sheet1!$A$3,0,0,360/Sheet1!$B$1,1),NA())
and
Name: C_100
Refers To: =IF(Sheet1!$E$3:$E$100=100,OFFSET(Sheet1!$C$3,0,0,360/Sheet1!$B$1,1),NA())
Then set the X and Y axis of the chart to SheetName!A_100 and SheetName!C_100
The if statement filters out all the points not at frequency 100, if you have a formula for selecting the frequency replace "Sheet1!$E$3:$E$100=100" with that.
The offset function takes the first cell in the column and expands the number of rows according to your 360/step size formula.

Excel chart : convert Y-axis values into Y-axis categories

I have some data of students grades in a French scale (double values ranging from 0 to 20).
At the moment, on a scatter chart (with lines connecting dots) which permits having dates as X-axis, I have grades as doubles on my Y-axis, and a series of end of term dates as X-axis.
With the following interval mapping :
A = [16;20]
B = [12;16[
C = [8;12[
D = [4;8[
E = [0;4[
I would like to have as Y-axis these letters for grades... How can I set this up in Excel/VBA ?
I don't know your situation - but I think the easiest way(from what I have seen looking on the web - this question has been asked before with no reasonable solution) is probably to just make your graph and then position text boxes containing "A" "B" "C" "D" "E" at the appropriate points along the y axis. - Kind of dumb I know - a fake axis - but it will get the job done.
Otherwise there might be a more specialized graphing program you could use.

How to draw a "Line with Markers" graph like this?

Please view this image (focus to red around area):
I cannot get it to work with the letters, but I can get it to work with numbers (=CODE(A1)-CODE("a")+1):
UPDATE after reading Jean-François's answer (but on another computer):
Added a second series just for the custom labels
Show data labels for the new series
Explicitly set the Y axis minimum at 0
Deleted the original X axis labels
Deleted the legend entry of the second series
A few more steps and we're there:
multiplied the X axis values by 10, to adjust granularity for positioning stuff
subtracted 5 for series1 values, to get the data in the middle between major tick marks
played with series2 values, to get the labels also in the middle between major tick marks
Here's an easier way.
Set up the data like this:
Select the first two columns (blue) and insert a column chart (zero value columns do not appear):
Select and copy third and fourth columns (red), select the chart, Paste Special as new series, check first column and first row boxes (it's added as another column):
Right click new column series, choose Change Series Chart Type, and select the XY with Lines style:
Right click XY series, choose Format Data Series, change to Primary Axis:

Resources