rrdtool: Display 2 values with correct size on y-axis - rrdtool

I want to display 2 values on the Y axis correctly with rrdtool.
The first value has a range of 0-70, the second from 0-800.
The scale of values should be appropriate. With --right-axis=0.1:0 I can adjust the naming on the right side, but the value is not "resized'd", so that e.g. a value "10" practically disappears on the 0 line when the 2nd value is 500.
Can this be done correctly?

The option you want is --right-axis 10:0 to display a second Y-axis that is scaled 10:1 with no offset. You then need to scale your second variable before you plot it so that it will be relative to the second axis.
Here is an example
rrdtool graph --right-axis 10:0 \
--vertical-label "Variable A" \
--right-axis-label "Variable B" \
DEF:a=file.rrd:a:MAX \
DEF:b=file.rrd:b:MAX \
CDEF:bb=b,10,/ \
LINE:a#ff0000:VariableA \
LINE:bb#00ff00:VariableB
Of course, if you want to print values for 'b' in the legend, then calculate them based on 'b' rather than 'bb'.
See here for the documentation: https://oss.oetiker.ch/rrdtool/doc/rrdgraph.en.html

Related

Coefplot- Event study plot with two coefficients at time zero

I have an event study I am plotting with coefplot in Stata 13. At time zero, I have two coefficients I would like to plot side by side, group A and group B. I don't know how to format the plot so that both coefficients show up side by side at time zero, without creating two separate plots or having a wide gap between them. Other than the two coefficients at time zero, there is only one coefficient at every other x-axis point. I would ideally like to label both group A and B at time zero with a different color but I can figure that out myself.
Here is the relevant code:
ppmlhdfe f2 ( 2.time 3.time 4.time 5.time zero c.groupA c.groupB 8.time 9.time 10.time 11.time 12.time )#(c.eventstudy_treat) , offset( log_pop_tt) a(i.unit i.month#i.year alltime#eventstudy_treat ) vce(cluster unit ) pformat(%5.4f) eform
Above, #.time is a dummy for each period in the event study where 7.time is "Time Zero". Period T-1 is a reference period represented by zero which is collinear and defaults to 1. groupA and groupB are dummies for treated group A and treated group B at time zero.
Below is my code for coefplot, where only group A is plotted at time zero:
coefplot, omitted keep(2.time#c.eventstudy_treat 3.time#c.eventstudy_treat 4.time#c.eventstudy_treat 5.time#c.eventstudy_treat 0.zero#c.eventstudy_treat c.groupA#c.eventstudy_treat 8.time#c.eventstudy_treat 9.time#c.eventstudy_treat 10.time#c.eventstudy_treat 11.time#c.eventstudy_treat 12.time#c.eventstudy_treat) vertical xlabel(1 "-5" 2 "-4" 3 "-3" 4 "-2" 5 "-1" 6 "0" 7 "1" 8 "2" 9 "3" 10 "4" 11 "5") baselevels eform order(2.time#c.eventstudy_treat 3.time#c.eventstudy_treat 4.time#c.eventstudy_treat 5.time#c.eventstudy_treat 0.zero#c.eventstudy_treat c.groupA#c.eventstudy_treat 8.time#c.eventstudy_treat 9.time#c.eventstudy_treat 10.time#c.eventstudy_treat 11.time#c.eventstudy_treat 12.time#c.eventstudy_treat) title("Event Study") xtitle("Relative Month") ytitle("Percentage Change") ciopts(recast(rcap)) transform(*=(#)-1) ylabel(-.06(.02).16,gmin gmax) yline(0, lpattern(dash) lcolor(gs0))
Picture is at:
https://i.stack.imgur.com/z4ZxW.png
How do I plot group B as well at time zero so that both groupA and groupB are plotted at time zero right next to each other? The group B coefficient is c.groupB#c.eventstudy_treat.

Retraining Inception and specifying label_count = 2 but receiving three scores instead of two

I have modified the flower retraining code to have label_count =2 as shown here:
gcloud beta ml jobs submit training "$JOB_ID" \
--module-name trainer.task \
--package-path trainer \
--staging-bucket "$BUCKET" \
--region us-central1 \
-- \
--output_path "${GCS_PATH}/training" \
--eval_data_paths "${GCS_PATH}/preproc/eval*" \
--train_data_paths "${GCS_PATH}/preproc/train*" \
--label_count 2 \
--max_steps 4000
And I have modified dict.txt to have only two labels.
But the retrained model outputs three scores instead of two as expected. The unexpected third score is always very small as shown in this example:
KEY PREDICTION SCORES
Key123 0 [0.7956143617630005, 0.2043769806623459, 8.625334885437042e-06]
Why are there three scores and is there a change one can make so the model outputs only two scores?
Note: I have read the answers from Slaven Bilac and JoshGC to the question “cloudml retraining inception - received a label value outside the valid range” but these answers do not address my question above.
It's the "label" we apply to images that had no label in the training set. The behavior is discussed in this comment in model.py line 221
# Some images may have no labels. For those, we assume a default
# label. So the number of labels is label_count+1 for the default
# label.
I agree it's not a very intuitive behavior, but it makes the code a little more robust against datasets that are not as cleaned up! Hope this helps.

Calculating normals for a height map

I have a small problem calculating normals for my heightmap. It has a strange behavior. At the higher and the lower points the normals are fine, but in the middle they seem wrong. They are lighted by a point light.
UNFIXED SOURCE REMOVED
EDIT:
Tried 2 new approaches:
This is per-face-normal. It looks fine but you see the single faces.
Position normal = crossP(vectorize(pOL, pUR), vectorize(pOR, pUL));
I also tried to do it per-vertex this way, but also with a strange output.
This is the suggestion Nico made:
It looks also rather odd. Maybe there is a mistake how I calculate the helping points.
UNFIXED SOURCE REMOVED
EDIT 2:
Definition of my points:
OL,OR,UL,UR are the corner vertices of the plane that is to be drawn.
postVertPosZ1 postVertPosZ2
preVertPosX1 pOL pOR postVertPosX1
preVertPosX2 pUL pUR postVertPosX2
preVertPosZ1 preVertPosZ2
EDIT3:
I solved it now. It was a stupid mistake:
I forgot to multiply the y value of the helping Vertices with the height Multiplier and had to change some values.
It is beautiful now.
There are lots of ways to solve this problem. I haven't encountered yours. I suggest using central differences to estimate partial derivatives of the height field. Then use the cross product to get the normal:
Each vertex normal can be calculated from its four neighbors. You don't need the plane plus its neighbors:
T
L O R
B
O is the vertex for which you want to calculate the normal. The other vertices (top, right, bottom, left) are its neighbors. Then we want to calculate the central differences in the horizontal and vertical direction:
/ 2 \
horizontal = | height(R) - height(L) |
\ 0 /
/ 0 \
vertical = | height(B) - height(T) |
\ 2 /
The normal is the cross product of these tangents:
normal = normalize(cross(vertical, horizontal))
/ / height(L) - height(R) \ \
= normalize | | 2 | |
\ \ height(T) - height(B) / /
Note that these calculations assume that your x-axis is aligned to the right and the z-axis down.

How do I set different column widths for each column of a tktable?

I have a table made using Python 2.7 and tktable v1.1 that looks like the following:
class GUI (Tkinter.Tk):
self.testTable = tktable.Table(self, rows = 30, cols = 30, state='disabled',titlecols=1,titlerows=1, \
selectmode='extended', variable=self.tktableArray, selecttype='row', colstretchmode='unset', \
maxwidth=500, maxheight=190, xscrollcommand = self.HScroll.set, yscrollcommand = self.VScroll.set) # Create the results table
self.testTable.grid(column= 2, row = 6, columnspan = 4) # Add results table to the grid
Irrelevant code was left out in order to not throw a wall of code up. My desire here is to size the column widths independently for each column. For instance in column 0 I have only 3 digit numbers and in column 1 I have a 10 character word. I know that I could use
self.testTable.configure(colwidth=10)
to set the widths of the columns but that applies to all columns. Is there a way to do this on a per-column basis? And even better, is there a way to make the column widths fit to the contents of the column? Any help is appreciated.
I've never used a tktable, but a quick read of the tktable documentation shows there's a width() method on the table object. Have you tried that?
# set width of column 0 to 3, column 1 to 10
self.testTable.width(0,3,1,10)
The right answer is:
columnwidth={'0':7,'1':12,'2':20,'3':35,'4':15,'5':15,'6':22}
self.table.width(**columnwidth)

What Date Source(DS) and Round Robin Archive(RRA) should I choose for displaying information about multiple website registrations per period?

What Date Source(DS) and Round Robin Archive(RRA) should I choose for displaying information about multiple website registrations per period?
I want have RRA with one measurement = 5min. period. The Y axis displaying total number (not average) of registrations during last 5 minutes. Also, I want graph with information about total number of registrations (Y axis) per day (X axis).
What DS type and RRA "algoritm" shoud I choose to implement this?
You should look at the rrd-beginners guide. Hope this helps you.
From the top of my head, this should create the DB with the correct DST:
rrdtool create file_name.rrd /
--start N --step 300 /
DS:registrations:COUNTER:600:U:U /
RRA:MAX:0.5:1:288
And this should produce the wanted readout:
rrdtool graph file_name.png --start -86400 \
--x-grid HOUR:1:HOUR:8:HOUR:2:0:%Hh \
--vertical-label "num" \
TEXTALIGN:center \
DEF:num_regs=file_name.rrd:registrations:MAX \
LINE:num_regs#1F77B4:"Number of registrations"
Let me know if it works :)