Gnuplot: Defining an x axis based on the order of my values - gnuplot

I have some data
20,10.00
21,10.00
22,10.00
23,09.00
00,10.00
01,10.00
...
I want to graph the first value on the x axis and the second value on the y axis. I want the y axis to be autoset but I want the x axis to follow in line with my data eg. 20, 21, ..., 0, 1... instead of 0, 1, ..., 23
I thought I would do this with xticlabels, stating plot "filename" using xticlabels(1):2 or, as inspired by this, 1:2:xticlabels(1). Neither has the desired effect. What am I to do?

Yes, you must use xticlabels to add individual labels. But now you must still specify some value for the x-axis. If you know, that the rows all have the same spacing, then use the zeroth column as x-value:
plot "filename" using 0:2:xticlabels(1)

For my specific case, setting xrange [23:0] will suffice. However, this is not dynamic as it does not apply in the case of unordered values, so I am still curious of how the problem would otherwise be solved.

Related

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.

Excel chart with only x axis and empty space beetween points

I need to draw Excel chart with only x axis and empty space between the points.
For example I will have points on x axis (1,3), (5,8), (9,10)
The line should go from 1-3 then empty then line from 5-8 then empty then line from 9,10
I tried something with Scatter graph but didn't manage to do it.
Basic-lay Y axis can exist but I will always use the same value
Any ides?
Here is screenshot to get the idea. It is not connected to mentioned points
Chart Example
In chart example points would be (3,5) , (7,8)
You can do something like this:
First in your data, add a empty row in your data where you want the space (row 10 in my example).
Choose a "Scatter plot with Straight Lines and Markers"
Then format your axis (right click on x-axis and choose format axis) to "Units" -> "Major": 1.
Notice how my empty space creates a gap between the two series (5,8) and (9,10).

GNUPLOT: boxplots variable line style/colors

I have multiple data files for which I want to draw a single figure. Each of the files contains a column with two variables: true and false. I would like to draw boxplot for each of these values such that they can be compared. Sample of data file is given below:
0.6,true
0.7,true
0.5,false
0.4,true
..
I come up with following code:
plot inputFile1 using (1):($4):(0.3):3 title 'A' , \
inputFile2 using (3):($4):(0.3):3 title 'B'
This generated the following figure:
However, I would like to customize it such that all the boxplots with "true" variable have one specific line style/color and boxplots with "false" variable have another specific line style/color.
Furthermore, I would like to show in the title the shape of true and false, however, on x-xis, I want to have File A and B for each true,false pair.
Any help in this regard would be highly appreciated.
Thanks in anticipation.
With your current datafile, you would need to detect whether the second column contains true or false and act accordingly. However, I am not sure gnuplot can process strings from a datafile.
If you process your file and replace the true or false by 1 or 0, then you can adapt the following line:
plot [0:6] "+" using 0:($0/2.):(0.3):0:xtic((int($0)%2)==0?"true":"false") w errorb lc variable
Here the 4th number in the using list defines the colour, with $0 the colour changes for each line of the file, but if the colour number is in one column of your file then use that column. Replace the "+" by your file and the first two numbers in using by the parameters needed by your plotting style. The xtic command processes some column in the file (here the line number $0) and labels the x tic depending on the value (see help ternary).
Note that your MWE does not work as is, please amend it if you want a more precise answer.

specifying points in space associated with a particular value in gnuplot

I have 10x10x10 grid points. Some of these points are associated with a value 1 and the others are associated with a value -1. I want to specify(give a color to) only those points which have value 1. Can anyone please tell me how this can be achieved in Gnuplot.
Thanks in advance.
If you want to filter out completely all points with value -1, you can do it as follows:
splot 'file' using 1:2:($4 == 1 ? $3 : 1/0) with points
That assumes, that your data file has four columns with the x, y, z value in the columns 1, 2, 3 and in the fourth column the values 1 or -1.
With the using statement you can specify which columns are used for plotting: using 1:2:3 uses the first column as x, the second as y and the third column as z value.
You can also do calculations inside the using statement. In that case you must put the respective expression in braces, and refer to the values of a column with e.g. $3 or column(3): using 1:2:($3/10) would scale the values in the third column by 10 and use the result as z value.
The expression I used above, using 1:2:($4 == 1 ? $3 : 1/0) does the following: If the value in the fourth column is equal to 1, use the value in the third column, otherwise use 1/0. The 'special' value 1/0 makes gnuplot ignore a point.

How does Excel determine the axis values for charts?

When Excel determines the axis values it will use to represent your data in a chart, the values are 'evenly distributed'.
For Example:
If you plot the following series in an Excel Line Chart.
[0.22,0.33,0.44,0.55,0.66,0.77,0.88,0.99,1.1,1.21,1.32,1.43,1.54,1.65,1.76,1.87,1.98,2.09,2.2]
Excel determines that the y-axis values should be [0,0.5,1,1.5,2,2.5].
What technique or formula is used to determine these values ?
After doing some experiementing, I conclude that Excel:
1) It will keep the Y axis starting at zero unless you explicitly tell it otherwise
2) It will set the Y axis max one major tick higher than your largest value
3) The last part seems more arbitrary - it clearly has "preferred" units (.1, .2, .5, 1, 2, 5, 10, 50, 100, etc) that it will choose for the major tick. It will use the smallest preferred unit that will result in between 5 and 10 major ticks, meeting the requirements above.
Please have a look at:
Reasonable optimized chart scaling
And
Algorithm for "nice" grid line intervals on a graph
There are more questions like this.

Resources