An expression for positioning an element - after-effects

I’ve got a problem with creating a proper expression when it comes to a position of an image.
I do have this expression placed in position: thisComp.layer("TA1").transform.position
My goal is adding to this expression (thisComp.layer("TA1").transform.position)
An extra line which can move the whole image by 200 pixels down
I don’t know what to type in order to make it work or how to solve it. I’ve tried to do my research on expressions but so far unable to find any answers myself.
Thank you in advance
enter image description here

To add to Stib's comment above (I still don't have enough rep to comment). You can use the pickwhip tool to access the individual x and y properties. The pickwhip tool is the one with the spiral icon below the property values.
If I click on the pickwhip and drag it to the x value of my position, I get:
temp = transform.position[0];
[temp, temp]
If I then add a line between those and pickwhip the y value, I'll have:
temp = transform.position[0];
transform.position[1]
[temp, temp]
Then I can change it to:
x = transform.position[0];
y = transform.position[1] + 200;
[x, y]
This should also give you what you want.
Of course this could also be done to a seperate layer giving you:
x = thisComp.layer("TA1").transform.position[0];
y = thisComp.layer("TA1").transform.position[1] + 200;
[x, y]

Related

Python:How to do operations on a grid

For a word game(something similar to image provided),where inside a grid various letters are entered on different tile,enter image description here I had to create a 6*6 grid and then do operations on it like:
a)place the tile on a specific location in the grid and
b)return the location of any tile on the grid
c)determining the top scoring words in the grid
Till now I have managed to create the grid but i have no clue of how to place a tile on a specific grid or fetch the location of a tile on the grid.I have created the following grid:
grid = [[" _" for x in range(6)]]
for y in range(6):
list1 = []
for x in range(13):
if x%2 == 0:
list1.append("|")
else:
list1.append("_")
grid.append(list1)
for row in grid:
print("".join(row))
I am new to python and any help would be appreciated.
Did you try to run this piece of code? I don't think so because the indentation here is bad, so it won't work.
You should rename your variable list1 to row for comprehension
purpose : your variable names should always be as descriptive as
possible.
Here to initialize in a more compact way your grid you could do:
grid = [["_" if x%2==0 else "|" for x in range(13)] for x in range(6)]
To access a specific tile you can do:
grid[y][x]
In example, the following command would print the cell on the third row second column:
print(grid[3][2])
To set the value you can do:
grid[y][x] = value
But I think that you should see a course about learning Python before trying to do these things.
Google it and good luck!

numpy.interpd -returning only the last value after interpolation

I have a set of data points in pressure(p) and vmr.
I want to find the vmr values for another pressure grid(pressure_grid).I used np.interp,
for lines in itertools.islice(input_file, i, l):
lines=lines.split()
p.append(float(lines[0]))
vmr.append(float(lines[3]))
x = np.array(p)
y = np.array(vmr)
yi=np.interp(pressure_grid,x,y)
But when I tried to print "yi" it is printing only the value(i.e.,vmr value) corresponding to the last value of "pressure_grid".For all iterations it is printing the same value
I tried to print p and vmr ,Everything seems to be fine till there.I'm not able to understand why this is happening...
I'm new to this........Please Help
This is how my file looks like,first column-p and second column-vmr.
and this is my pressure grid
https://1drv.ms/t/s!AmPNuP3pNnN8g35NPwIfzSl-VBeO
https://1drv.ms/f/s!AmPNuP3pNnN8hAx3opovgipabSjJ
There are two issues with your code. First x and y are being overwritten for each iteration of the for loop, which means, x and y contain just a single element for the interpolation. To fix this, you could define x and y list outside the loop and append in the for loop, or more simply, just use numpy.loadtxt():
import numpy as np
data = np.loadtxt('demo.txt',comments='<',usecols=[0,2])
Here, I have specified to skip rows beginning with a less than sign, so we only get the actual data.
Second, for numpy.interp to actually work, you need the x-coordinate to be an increasing sequence. (check the notes). For your data, x is a decreasing sequence, so you should flip the data after loading it:
x = data[::-1,0]
y = data[::-1,1]
interpolation = np.interp(grid,x,y)
Alternatively, you could just use the scipy.interpolate package on the original, unflipped data. This has the added advantage of allowing you to extrapolate data that isn't enclosed by your input domain:
from scipy import interpolate
interpolation = interpolate.interp1d(x,y,fill_value='extrapolate')
Note: your input file appears to have more than one <Matrix> </Matrix> set. To get all this to work, I trimmed the file so it only contained one dataset. Otherwise, your x input data will not be strictly increasing, even after flipping, and you will have to sort.

Extract all occurences of a particular type in Haskell

I am writing some programs in Haskell which manipulate Haskell source code in certain ways. One of the things I would like to be able to do is to extract all occurrences of a particular type (and possibly their positions as well).
I figured a very crude method using regular expressions would work for simple data types. For example, in the following graphics code:
module Test where
import Picture
r1,r2,r3,r4 :: Region
r1 = Shape(Rectangle 2 2)
r2 = Shape(Ellipse 2 1.5)
r3 = Shape(RtTriangle 3 2)
r4 = Shape(Polygon [(-2.5, 2.5), (-3.0,0), (-1.7,-1.0), (-1.1,0.2),(-1.5,2.0)])
p1,p2,p3,p4 :: Picture
p1 = Region Red r1
p2 = Region Green r2
p3 = Region Blue r3
p4 = Region Yellow r4
pic :: Picture
pic = foldl Over EmptyPic [p1,p2,p3,p4]
I could extract every number by simply creating a regular expression which looks for every instance of numeric characters with no letters surrounding them. Likewise If I wanted to find all colours, I could hard code a regular expression which searches for occurrences of Red or Green or Blue... etc.
The problems as I see it with this method are:
If I ever want to change the type I am searching for, I have to hard code every possible way that type could manifest itself
It doesn't work if the type value is returned as the result of a function call. For example, if p1 instead read:
p1 = Region (getColor 1) r1
where:
getColor :: Int -> Color
getColor n
|n == 1 = Red
|otherwise = Green
Is there a more general way to parse a Haskell file so as to extract all occurrences of a particular type and, if possible, their positions within the text of the source file?
You can use a parser, namely haskell-src-exts, which preserves position information (line and column numbers) in the output AST.

Remove blanks at ends of DataVisualization chart x axis

I am using Microsoft's DataVisualization.Charting.Chart, and I have integer values along the X axis, using line-style graphs. However, the chart is adding an extra blank item at the beginning and end of the x-axis, with no value labels to explain what they are.
How can I remove these empty items and make the lines go right up to the ends?
Use the IsMarginVisible property of the xaxis. I believe that will do the trick.
To test this, I changed one of my own charts to be a line chart and then set the value in the code:
ReactivityChart.ChartAreas(0).AxisX.IsMarginVisible = False
Tell me if this is what you were hoping to get or if I have totally misunderstood the question:
(note that I do not have a high enough rep to post this image)
http://www.rectorsquid.com/chartmargintest.gif
You should set the Maximum and Minimum properties in ChartArea.AxisX, e.g. :
this.chart1.ChartAreas[0].AxisX.Minimum = 0; // if your minimum X = 0
this.chart1.ChartAreas[0].AxisX.Maximum = 100; // if your maximum X = 100
In this way, your chart area will show only the values between Minimum and Maximum.

D3 refresh axes labels

I have a graph that I show two sets of data in it. The user can hit a button to flip to another set of data. The problem is the axes aren't the same, but when I want to update the ticks I instead just layer on top another axis.
http://jsfiddle.net/scottieb/VjHd6/
The key bit is at the end:
vis.selectAll("axis").remove();
vis.append("svg:g")
.attr("class", "x axis")
.attr("transform", "translate(0, " + (h - margin ) + ")")
.call(d3.svg.axis()
.scale(x)
.tickSize(0)
.tickSubdivide(true)
.tickFormat(formatCurrency)
);
I've tried selectAll("g").remove(), but that prevents laying down the next axis. Any ideas?
Whoops, needed to redefine the scale and call a transition rather than just build a whole new axis.
http://jsfiddle.net/scottieb/JwaaV/
Your issue is that your selector is not correct. Instead of selecting "axis", you should select ".axis" since you are appending a "g" node with a class.