How to set a property for all sets in xmgrace in a single statement - batch-processing

Suppose I have file1.dat and file2.dat. I want to plot them and, for both sets, set the line-width of to 2 (for error-bars too) and the symbol to a circle. Currently, I invoke
xmgrace -batch batch.xmg
with this batch.xmg:
READ XYDY "file1.dat"
READ XYDY "file2.dat"
S0 LINEWIDTH 2
S0 SYMBOL 1
S0 ERRORBAR LINEWIDTH 2
S0 ERRORBAR RISER LINEWIDTH 2
S1 LINEWIDTH 2
S1 SYMBOL 1
S1 ERRORBAR LINEWIDTH 2
S1 ERRORBAR RISER LINEWIDTH 2
It works as expected, however batch.xmg becomes big and very repetitive as the number of data files (and, consequently, sets) increases. Besides, whenever I want to modify a common property, I have to go through all sets and change the corresponding value (or to employ a text-processing tool such as sed).
Then, I ask: Is there any way to make a global statement that sets a property for all sets? For example, something like
SETS SYMBOL 1
I thought that statement would work according to this manual, but it does not. Xmgrace raises an error and draws no symbol for all sets.

I had overlooked the Defaults section. These statements are available:
DEFAULT LINESTYLE number
DEFAULT LINEWIDTH number
DEFAULT COLOR number
DEFAULT CHAR SIZE number
DEFAULT FONT number
DEFAULT SYMBOL SIZE number
DEFAULT SFORMAT number
I found out that you need to write them before the read statements if you want the defaults to apply to them. For example, this will set the line-width and line-style for file2.dat, but not for file1.dat:
READ XYDY "file1.dat"
DEFAULT LINEWIDTH 3
DEFAULT LINESTYLE 3
READ XYDY "file2.dat"
However, notice that, unfortunately, not all properties are available (for instance, you can't set DEFAULT SYMBOL 1).

Related

How do I correctly describe this 4x4 square in my K-map?

I am trying to find a (SoP)-expression using the embedded K-map. I have a box of size 4x4 which is a permitted use however I am having a hard time understanding how I could implement it.
To me the 4x4 box represents that the output is always 1 independet on any of the variables. Then I'd like to use the 2x4 box to the right and produce:
1 OR (Qc AND !Qd), but this does not produce the correct result.
I can see several alternative ways to produce the correct result. My questions are specifically:
Why can't I use the 4x4 box, or perhaps, how do I represent it correctly?
How do I know when I can represent parts of the output as a 4x4 box?
Perhaps Im missing something more fundamental.
Thx in advance.
The point of placing rectangles in a K-map is to eliminate variables from an expression. When the result of a rectangle is the same for the variable values X and X', then the variable X is not needed and can be removed. You do this by extending an existing rectangle by doubling the size and eliminating exactly one variable, where every other variable stays the same. For the common/normal K-map with four variables this works with every such rectangle because in a way the columns/rows are labelled/positioned. See the following example:
The rectangle has eliminated the variables A and B, one variable at a time when the size of the rectangle has been extended/doubled. This results in the function F(A,B,C,D) = C'D'. But check the following K-map of four variables:
Notice that the columns for the D variable has been changed (resulting in a different function overall). When you try to extend the red rectangle to catch the other two 1 values as well, you are eliminating two variables at the same time (B and D). As you cannot grow the rectangle anymore, you are left with two rectangles, resulting in the function F(A,B,C,D) = BC'D' + B'C'D (which can be simplified to C' * (BD' + B'D)).
The practice in placing rectangles in the K-map isn't just placing the biggest rectangle possible, but to eliminate variables in the right way. To answer your questions, you can always start with the smallest rectangle and extend/double its size to eliminate one variable. See the following example:
The green rectangle grows in these steps:
Start with A'BC'D'E
Eliminate the (only) variable A by growing "down", resulting in BC'D'E
Eliminate the (only) variable D by growing "right", resulting in BC'E.
But now, the rectangle cannot grow/double its size anymore because that would eliminate the variable E, but also somehow eliminate the variable C. You cannot eliminate the variable E, because you have 0 values to the left of the green rectangle and 1 values to the right of the green rectangle (all in the left half of the K-map, where you have the value C'). The only way to increase/grow the rectangle is to get the "don't care" values to eliminate the B variable (not shown here).
The overall function for this K-map would be F(A,B,C,D,E) = C'E + DE' + CD' (from three 2x4 rectangles).

How to place half-block slabs in Minecraft with MakeCode

This is a bit of a long-shot. I really don't know where to ask this question.
I've been trying out CodeConnection + MakeCode with Minecraft and I haven't been able to figure out if there is correct way to place half-slabs at 0.5 step y axes increments.
I tried using a line between 2 points, but it left gaps between each slab.
If I try moving up 0.5, then it rounds it up to 1, and again leaves gaps.
It appears that all of the builder functions seem operate at a resolution of 1 block. However in-game I can obviously place slabs in 0.5 block increments to make stairs etc.
Blocks only exist at integer coordinates. Half slabs that exist in the top half of their space are still at a full integer coordinate. They just have a BlockState value of bottom=top (or top_slot_bit=true on Bedrock, represented by the integer value 8 as a bitflag, eg: 0b1... where the . bits are the integer representation of what type of slab (wood, stone, quartz...)).
What you're looking for is this widget, under Blocks:
You can set the block and then an integer representation of the desired data value (see the wiki on data values) in the numerical slot. This widget can then be dragged into the (block) portion of any block widget:
You'll probably have to some variable fiddling to get the data value to swap back and forth as you need it to, but that should solve the hurdle you've been facing.

Gnuplot summation issue

I am trying to make a plot of a simple mutation accumulation process on a binary tree...
My technical problem in gnuplot, is that is that I want to plot the possibility of getting 2 mutations on a specific lineage on the graph, here is the equation which determines it:
P_{2 mutation} = sum[k=0:n] (m/(2**(k+1)/(1-(1/2)**k)))(1-exp(-muk))
(dont bother with the formula im not sure that this is the correct one yet :))
where n is the number of levels of the binary tree, mu is the mutation rate, and m is the number of previously randomly thrown mutations onto the graphs edges...
I want to make a plot which is this possibility depending on the levels of the binary tree...
Therefore I wrote a script which is something like this:
set term pngcairo size 800,600
set title "Két mutáció megjelenésének valószínűsége, egy n szintű bináris fa egyik sejtvonalában"
set xlabel"szintek száma (n)"
set ylabel"Két mutáció megjelenésének valószínűsége (P_{2^{lin})"
set xrange[1:10]
set yrange[0:1]
set output '2mutvalsz.png'
set multiplot
do for[i=1:10]{
mu = 0.1+(i*0.1)
m = 4
f(x)=(x/((2**(x+1))*(1-(0.5)**x)))
if(m<floor(f(x)))
{
p(x)=sum [k=0:floor(x)](m*(1/((2**(x+1))*(1-(0.5)**x))))*(1-exp(-mu*k))
}
else
{
p(x)=1
}
plot p(x) lt i lw 1
}
unset multiplot
set output
So my problem is, that I dont know if it is correct to do what I do in the
if statement...
What I want is to behold the statement m< f(x) where f(x) is the number of edges in respect of n, which is an integer value therefore I use floor(f(x)), and sum through the x values (which are the number of levels what has to be an integer too... so floor(x), like a heavyside function to make the x axis discrete) in the sum...
And also I get an error message:
gnuplot> load '2mutvalsz.plt'
line 27: undefined variable: x
where line 27 is the end of the do for loop...
So my question is that is it a correct way to make a summation integer the x values and of course why I get the error message...
Thank you, and I hope everything is clear...
The error message is produced because the if statement in your script is interpreted when Gnuplot loads the script - it tries to evaluate the condition of the if statement and since the variable x is not defined, it produces the mentioned message.
You could put everything together using the ternary operator as:
p(x)=( m<floor(f(x)) )?( sum [k=0:floor(x)](m*(1/((2**(x+1))*(1-(0.5)**x))))*(1-exp(-mu*k)) ):1;
However, since the function f(x) is on the imposed x-range of [0,1] less than 1, the condition m<floor(f(x)) will be always false.

Cannot change polygon 'size' every repeat in Builder

I'm using Builder v1.80.06
I can vary the position of a polygon every repeat easily enough
e.g. I have a Positions list
positions=[[1,1],[1.1,0.9],...]
and in the 'Position field' have :
$positions[0]
and then change it's value in a code block on each repeat.
BUT I want to vary the size in a similar manner with a $sizes list but get an error.
Looking at the generated code, the problem is at the object creation stage. the code generated is:
for a hard coded polygon (ie ok)
polygon_1 = visual.Rect(win=win, name='polygon_1',
width=[1.5, .2][0], height=[1.5, .2][1],
ori=0, pos=[0, -0.6],
lineWidth=1, lineColor=[1,1,1], lineColorSpace=u'rgb',
fillColor=[0,1,0], fillColorSpace=u'rgb',
opacity=1,interpolate=True)
for one populated by a variable (not working):
polygon_2= visual.Rect(win=win, name='polygon_2',
width=1.0[0], height=1.0[1],
ori=0, pos=[0,0],
lineWidth=1, lineColor=[1,1,1], lineColorSpace=u'rgb',
fillColor=[1,0,0], fillColorSpace=u'rgb',
opacity=1,interpolate=True)
It complains (rightly) that 1.0[0] makes no sense on the width and height parameters
Even though I have my sizes list instantiated in a code block right at the beginning of the experiment instead of reading $sizes[0] a default float value of 1.0 is used.
Any other suggestions for how to vary the polygon size dynamically at runtime using builder?
I could just take the generated code and drop it into coder I suppose and fix the problem but I want to hand this over to a researcher so would like for them to be able to maintain it.
thanks,
If you set size to be a tuple/list with a pair values [1.2,1.5] or [1,1] does that not fix it?
When you change attributes at runtime, just change the attribute of an existing stimulus instead of instantiating a full new stimulus. The latter is quite heavy on ressources, causing unreliable timing. So do
stim = visual.Rect(win) # instantiation, ressource heavy
stim.attribute = newValue # change attribute. lighter.
I can think of two ways you could do it in a pretty neat way. The first is to set width and height explicitly instead of the size attribute, but using a size-like value. So (removing all parameters not of interest):
polygon_2 = visual.Rect(win)
# Unpack the x,y-sizes to the stimulus .width and .height attributes
newSize = (1.5, 0.2)
polygon_2.width, polygon_2.height = newSize
The second, if the size attribute is really important to use, is to use the Polygin with edges=4 to make it a rectangle:
polygon_2 = visual.Polygon(win=win, edges=4, size=(1.5, 0.2))
# Setting size
polygon_2.size = (0.8, 0.4)
Do try Jon's suggestion first. But the idea with visual.Rect and visual.Circleis to use substitute Polygon's size and vertices for something more relevant. So size can do unexpected things if width/height etc. are not 1.

size of node with shape=circle

i'm trying to set the size of the nodes this way:
controller[shape=circle,width=.5,label="Controller",style=filled,fillcolor="#8EC13A"];
But all three nodes are with different size. How can i set fixed size?
From the DOT Guide http://www.graphviz.org/pdf/dotguide.pdf on page 4 it says the following:
When drawn, a
node’s actual size is the greater of the requested size and the area needed for its text
label, unless fixedsize=true, in which case the width and height values
are enforced.
Thus you simply need to add fixedsize=true to your code