I'm trying to make plot with GNU Plot for some data of experiments, but I cannot figure how to remove the redundant padding/space between Y axis and the first sample (left side of the first sample):
Code:
set terminal pngcairo size 800,800 enhanced font 'WenQuanYiZenHei,12'
set title "All Elements"
set xlabel "Sample"
set ylabel "Element Amounts"
set ytics nomirror
set style fill transparent solid 0.5 noborder
plot data u 2:xticlabels(1) w histograms title "K",\
data u 3:xticlabels(1) w histograms title "Ca",\
data u 4:xticlabels(1) w histograms title "Mg",\
data u 5:xticlabels(1) w histograms title "Fe",\
data u 6:xticlabels(1) w histograms title "Mn",\
data u 7:xticlabels(1) w histograms title "Zn"
Data:
| Sample | K | Ca | Mg | Fe | Mn | Zn |
|--------+-------+-------+------+--------+-------+------|
| -Ca 1U | 58800 | 4800 | 2700 | 222.5 | 28.0 | 30.0 |
| -Ca 2U | 59000 | 5475 | 3200 | 105.5 | 29.5 | 35.0 |
| -Mg 1U | 57600 | 12275 | 2900 | 92.0 | 45.5 | 37.0 |
| -Mg 2U | 57200 | 13850 | 3200 | 266.0 | 59.5 | 39.0 |
|--------+-------+-------+------+--------+-------+------|
| -Ca 1D | 19700 | 1100 | 3400 | 1708.0 | 79.0 | 48.5 |
| -Ca 2D | 20900 | 1025 | 3300 | 1812.0 | 102.5 | 54.5 |
| -Mg 1D | 23200 | 3175 | 3200 | 312.0 | 49.5 | 61.0 |
| -Mg 2D | 21800 | 4325 | 2300 | 2136.0 | 86.5 | 55.5 |
That's because of the header line in the data. You can skip it with
plot data every ::1 u 2: ...
Or just remove it before feeding the data to gnuplot.
Related
I have the following dataframe:
------------------------------------------------------------
| Month | low_temp | high_temp | Wages | Extreme |
------------------------------------------------------------
| Jan | 0 | 3 | -0.42 | 1000 |
------------------------------------------------------------
| Jan | 1 | 3 | 0.56 | 3000 |
------------------------------------------------------------
| Feb | -1 | 2 | -0.61 | 2000 |
------------------------------------------------------------
| Feb | 0 | 1 | 0.36 | 3500 |
-------------------------------------------------------------
| Mar | 1.5 | 4 | -0.25 | 3000 |
-------------------------------------------------------------
| Mar | 2 | 5 | 0.75 | 4000 |
-------------------------------------------------------------
| Apr | 3 | 5 | -0.55 | 3000 |
------------------------------------------------------------
| Apr | 3.25 | 4 | 0.24 | 6000 |
-------------------------------------------------------------
What I'm trying to do is create one continuous plot with two x axes.
So, it would have the follow features:
one y-axis for low_temp and high_temp.
two lines: low_temp, high_temp
x_axis1 (the important one): Extreme
x_axis2 (below or above the x_axis1, lines up with it but isn't used to plot anything): Wages
And then, for each Month, create this chart and then string it together horizontally
so it ends up:
y --------------------------
| | | | |
| jan | feb | mar | apr |
-------------------------
x axis 1
x axis 2
This is my code attempt but it causes the x-axis to not be in line at all!
for index, month in enumerate(Months):
a = df[df['Month']==month].sort_values(by='Extreme')
x = a['Extreme']
y_1 = a['low_temp']
y_2 = a['high_temp']
plt.subplot(1,4,index+1)
plt.plot(x,y_1,'bo-')
plt.plot(x,y_2, 'ro-')
plt.xticks(a.Wages)
plt.title(month)
plt.show()
The charts also appear in a vertical line so they aren't horizontally contiguous.
Any help is very much appreciated! thanks!
Horrible title, but I couldn't find a way to describe what I'm trying to do concisely. This question was posed to me by a friend, and I'm usually competent in Excel, but in this case I am totally stumped.
Suppose I have the following data:
| A | B | C | D | E | F | G | H |
---------------------------------------------------------------------
1 | 0.50 | 0.50 | 1 | | | 0.30 | 0.30 | |
2 | 0.25 | 0.75 | 2 | | | 0.40 | 0.70 | |
3 | 1.00 | 1.75 | 8 | | | 0.30 | 1.00 | |
4 | 0.75 | 2.50 | 2 | | | 0.50 | 1.50 | |
5 | 1.25 | 3.75 | 3 | | | 1.75 | 3.25 | |
6 | 0.50 | 4.25 | 1 | | | 0.25 | 3.50 | |
7 | 1.00 | 5.25 | 0 | | | 0.50 | 4.00 | |
8 | 0.25 | 5.50 | 2 | | | 0.30 | 4.30 | |
9 | 0.25 | 5.75 | 9 | | | 0.25 | 4.55 | |
10 | 0.75 | 6.50 | 4 | | | 0.70 | 5.25 | |
11 | | | | | | 1.00 | 6.25 | |
12 | | | | | | 0.25 | 0.25 | |
Column A represents the distance traveled while the measurement in column C was collected. Column B represents the total distance traveled so far. So C1 represents some value produced during the process from distance 0 to 0.5. B2 represents the value from distance 0.5 to 0.75, and B3 represents the value from 0.75 to 1.75, etc...
Column F represents a PLANNED second iteration of the same process, but with different measurement intervals. What I need is a way to PREDICT column H, based on a WEIGHTED AVERAGE of values from column C, based on where the intervals in column F intersect with the intervals in column A. For example, since F2 represents the measurement taken from distance 0.30 to 0.70 (an interval of 0.4, split 50/50 across the measurements in C1 and C2), H2 would be equal to: C1*0.5 + C2*0.5: 1.5.
Another example: H3 represents the expected measurement from an interval between 0.7 and 1.0, which is split between C2 (from 0.7 to 0.75 = 0.05) and C3 (from 0.75 to 1.0 = 0.25). So H3 = 16.6%*C2 + 83.3%*C3 = 0.332+6.664 = 6.996.
I'm looking for a way to do this in an Excel spreadsheet without using VBA or breaking it down into something like a Python script to process externally, but so far I'm not finding any way to do it.
Any ideas for accomplishing this entirely within Excel without any special add-ins/scripts installed ?
It's not pretty, but I think the following should work for all except H1 (which would need an added zero row):
=(MAX(0,INDEX(B:B,MATCH(G2,B:B,1))-G1)*INDEX(C:C,MATCH(G2,B:B,1)) +
(G2-INDEX(B:B,MATCH(G2,B:B,1)))*INDEX(C:C,MATCH(G2,B:B,1)+1)) /
MAX(G2-G1,G2-INDEX(B:B,MATCH(G2,B:B,1)))
It matches the values in B and C and weights them accordingly.
I have a questionnaire with answers in a number of different formats. I want the range to be between -1 and 1. However, not all ranges include negative numbers.
I need to create an excel formula to convert the value to the following dependent upon the range.
+---+--------+
| A |To this |
+---+--------+
|-3 | -1 |
|-2 | -0.66 |
|-1 | -0.33 |
| 0 | 0 |
| 1 | 1 |
+---+--------+
Or
+---+--------+
| A |To this |
+---+--------+
| 0 | 0 |
| 1 | 0.25 |
| 2 | 0.5 |
| 3 | 0.75 |
| 4 | 1 |
+---+--------+
Or
+---+--------+
| A |To this |
+---+--------+
| 1 | 0.2 |
| 2 | 0.4 |
| 3 | 0.6 |
| 4 | 0.8 |
| 5 | 1 |
+---+--------+
Or
+---+--------+
| A |To this |
+---+--------+
|-2 | -1 |
|-1 | -0.5 |
| 0 | 0 |
| 1 | 0.5 |
| 2 | 1 |
+---+--------+
etc.
This formula should do the trick:
=IFERROR(IF(A1<=0,-1*A1/(MIN(A:A)+MIN(0,MAX(A:A))),A1/(MAX(A:A))),0)
This produces this example output when autofilled down:
-3 -1
-2 -0.666666667
-1 -0.333333333
0 0
1 0.2
2 0.4
3 0.6
4 0.8
5 1
Note: this includes 0 for both sets of -1,0 and 0,1
If the range of input numbers is finite, even with negative numbers, you can use the general range mapping formula as below.
If the range of input numbers is [X1:X2] and the range of output numbers is [Y1:Y2] (in your case [-1:+1]) then number x is mapped to number y in the output range with the following formula:
y = (x - X1) * (Y2 - Y1) / (X2 - X1) + Y1
when X2-X1 != 0
Looking for some help here at aggregating more than 60,000 data points (a fish telemetry study). I need to calculate the median of acceleration values by individual fish, date, and hour. For example, I want to calculate the median for a fish moving from 2:00-2:59PM on June 1.
+--------+----------+-------+-------+------+-------+------+-------+-----------+-------------+
| Date | Time | Month | Diel | ID | Accel | TL | Temp | TempGroup | Behav_group |
+--------+----------+-------+-------+------+-------+------+-------+-----------+-------------+
| 6/1/10 | 01:25:00 | 6 | night | 2084 | 0.94 | 67.5 | 22.81 | High | Non-angled |
| 6/1/10 | 01:36:00 | 6 | night | 2084 | 0.75 | 67.5 | 22.81 | High | Non-angled |
| 6/1/10 | 02:06:00 | 6 | night | 2084 | 0.75 | 67.5 | 22.65 | High | Non-angled |
| 6/1/10 | 02:09:00 | 6 | night | 2084 | 0.57 | 67.5 | 22.65 | High | Non-angled |
| 6/1/10 | 03:36:00 | 6 | night | 2084 | 0.75 | 67.5 | 22.59 | High | Non-angled |
| 6/1/10 | 03:43:00 | 6 | night | 2084 | 0.57 | 67.5 | 22.59 | High | Non-angled |
| 6/1/10 | 03:49:00 | 6 | night | 2084 | 0.57 | 67.5 | 22.59 | High | Non-angled |
| 6/1/10 | 03:51:00 | 6 | night | 2084 | 0.57 | 67.5 | 22.59 | High | Non-angled |
+--------+----------+-------+-------+------+-------+------+-------+-----------+-------------+
I suggest adding a column (say hr) to your data (containing something like =HOUR(B2) copied down to suit) and pivoting your data with ID, Date, hr and Time for ROWS and Sum of Accel for VALUES. Then copy the pivot table (in Tabular format, without Grand Totals) and Paste Special, Values. On the copy, apply Subtotal At each change in: hr, Use function: Average, Add subtotal to: Sum of Accel then select the Sum of Accel column and replace SUBTOTAL(1, with MEDIAN(. Change Average to Median if required.
I have a certain number of measurements. Each in the following form:
Table A:
| Time [s] | Value |
| 0.5 | 2.0 |
| 50.3 | 33.7 |
| 100.0 | 25.5 |
Table B:
| Time [s] | Value |
| 1.3 | 12.7 |
| 27.8 | 25.0 |
| 97.5 | 20.0 |
| 100.0 | 7.1 |
Table C:
...
The time is always the same, from 0.0 seconds to 100.0 seconds.
The measurement-points as to be seen in the example differ.
I now want to display the different measurements in one chart. Each table has its own line-graph. The X-Axis would display the Time.
Is something like this possible in Excel?
Solved my problem by using a Scatter graph instead of a Line graph...