how to pass plot arguments when using split for multivariate point process - spatstat

To learn some plotting in spatstat, I am trying to plot database mucosa using the split function to create a multivariate plot. I get two different subplots of mucosa, but by default they both have the same symbology.
library(spatstat)
plot(split(mucosa))
Now in the two subplots, I would like to customise each subplot in terms of colour, size, shape etc. How can I do this? please advice.
I tried to pass pch and cex and col as a vector of two elements (because I know it is two types), but I get error
plot(split(mucosa), pch=c(19,3))
Error in symbolmap(..., chars = chars, cols = cols) :
Argument ‘pch’ is neither a function nor a constant

It seems untraditional to plot the types with different plotting characters when they are split into different panels. Why do you want to do that?
If you plot them in the same single plot you can just do as you suggest:
plot(mucosa, pch = c(19, 3))
And here you can add cols, cex, ...
However, if you first split the point pattern the more complicated plot.listof is called and you can look at that help file for details. Also if you look at our book Baddeley, Rubak and Turner (2015) you may find multi-panel plots which may inspire you. On the companion website for the book you can find code to generate all the figures of the book (requires a bit of searching though).

Use the argument chars instead of pch to specify several plotting characters.
In the call to split, you need to specify the argument un=FALSE which ensures that each of the split point patterns retains its original mark information (i.e. the type of each point).
So you need
plot(split(mucosa, un=FALSE), chars=c(19,3))

Related

Is there a way to dull/fade the coloring of marks in Altair?

I have the following DataFrame (only a part of it is shown):
I use it to generate the following plot in Altair. I generated this plot based on a modification of the code suggested in this post.
However, due to the fact that each of my Y labels has a different number of associated data points, the only way I could make the plot appear as desired was by using np.resize to repeat values. This works almost perfectly, but leads to the unfortunate issue that some of the marks in the plot appear darker than others, which can be misleading because it does not actually relate to the data in any way. Is there any way to get around this in Altair?
It sounds like you're asking about the opacity of the marks, which defaults to semi-transparent. You can adjust this with the opacity argument to mark_point(); for example:
alt.Chart(data).mark_point(opacity=1)

How to identify joints in the profile of a shape?

I'm working on a system to automatically take 2D profiles of components and assemble them into 3D shapes.
Imagine given these pieces:
You want to make this shape:
I'm highlighting one of the components to show how they fit together.
I'm open to any suggestions on how to go about doing this but the current approach I'm attempting first finds joints that may fit together just by looking at the 2D profile.
How could I go about identifying the "tabs" from the polyline profile?
The same technique should also work on assemblies like such:
see How to compare two shapes?
so you basically trying to find the "same" sequences in polylines encoded in the polar increment format (turn angle, line length) and then just check if relative position of matched sequences are the same in both shapes ...
Beware that the locks might have some gap between the joined shapes to ensure assembly is possible... in same case the gap might be even negative (overlap) depends on material and function so You need to compare the sequences with some margin ...
Also I would divide each shape into its sides to speed up the process as the lock is most likely not crossing sides ...
You may define the "code" for a tab. For example:
3,C,5,C,3 would mean: Three units length, then turn 90º counter-clockwise, then 5 units length, then turn 90º counter-clockwise, then 3 units length.
Of course more identifiers than C can be used, for different angles and so.
A tab in another piece that fits in the tab of the first piece has the same (or very similar) 3,C,5,C,3 code
So, finding same code in both pieces may be a fit. Check if adjacents codes in both pieces also fit, and you're done.
Notice that pieces can be rotated. This case doesn't change the code, but may change the order of adjacents codes.

Fitting multiple curves to one data set

I have a data set that I receive from an outside source, and have no real control over.
The data, when plotted, shows two clumps of points with several sparse, irrelevant points. Here is a sample plot:
There is a clump of points on the left, clustered around (1, 16). This clump is actually part of a set of points that lies on (or near to) a line stretching from (1, 17.5) to (2.4, 13).
There is also an apparent curve from (1.75, 18) to (2.75, 12.5).
Finally, there are some sparse points above the second curve, around (2.5, 17).
Visually, it's not difficult to separate these groups of points. However, I need to separate these points within the data file into three groups, which I'll call Line, Curve, and Other (the Curve group is the one I actually need). I'd like to write a program that can do this reasonably well without needing to visually see the plot.
Now, I'm going to add a couple items that make this much worse. This is only a sample set of data. While the shapes of the curve and line are relatively constant from one data set to the next, the positions are not. These regions can (and do) shift, both horizontally and vertically. The only real constant is that there's a negative-slope line from the top-left to the bottom-right of the plot, an almost curve from the top-center to the bottom-right, and most of the sparse points are in the top-right corner, above the curve.
I'm on Linux, and I'm out of ideas. I can tell you the approaches that I've tried, though they have not done well.
First, I cleaned up the data set and sorted it in ascending order by x-coordinate. I thought that maybe the points were sorted in some sort of a logical way that would allow me to 'head' or 'tail' the data to achieve the desired result, but this was not the case.
I can write a code in anything (Python, Fortran, C, etc.) that removes a point if it's not within X distance of the previous point. This would be just fine, except that the scattering of the points is such that two points very near each other in x, are separated by an appreciable distance in y. It also doesn't help that the Line and Curve draw near one another for larger x-values.
I can fit a curve to a partial data set. When I sort the data by x-coordinate, for example, I can choose to only plot the first 30 points, or the last 200, or some set of 40 in the middle somewhere. That's not a problem. But the Line points tuck underneath the Curve points, which causes a problem.
If the Line points were fairly constant (which they're not), I could rotate my plot by some angle so that the Line is vertical and I can just look at the points to the right of that line, then rotate back. This may the best way to go about doing this, but in order to do that, I need to be able to isolate the linear points, which is more or less the essence of the problem.
The other idea that seems plausible to me, is to try to identify point density and split the data into separate files by those parameters. I think this is the best candidate for this problem, since it is independent of point location. However, I'm not sure how to go about doing this, especially because the Line and Curve do come quite close together for larger x-values (In the sample plot, it's x-values greater than about 2).
I know this does not exactly fall in with the request of a MWE, but I don't know how I'd go about providing a more classical MWE. If there's something else I can provide that would help, please ask. Thank you in advance.

How to calculate the Standard Deviation of a column inside gnuplot

Hello I want to know how I can calculate the standard deviation of a column of a data file using gnuplot. I know gnuplot to refer to a column using n $ n, but how do I (could serve a function) to add all values ​​of $ n. That's all I can't do in gnuplot and they do not want to have to use some external program. And since gnuplot uses the notation $ n, I guess that this is possible, but not how. Any suggestions?
there is a command for that: stats
example for using the whole 2nd column:
stats "filename" using 2 name "A"
this gives you detailed information in the terminal and you can use the data with the suffix (here "A") like:
plot "filename" t "data", A_mean t "mean value"
see also help stats for more information on the command
Play some tricks, gnuplot can do this kind of work. I have talked about "Statistic analysis using gnuplot" in two of my blog articles. The mean value, maximum, minimum, standard deviation are all covered. Here is the urls:
http://gnuplot-surprising.blogspot.com/2011/09/statistic-analysis-using-gnuplot-0.html
http://gnuplot-surprising.blogspot.com/2011/09/statistic-analysis-using-gnuplot-1.html
May be you can find what you want from these two articles!
AFAIK gnuplot cannot manipulate data of a complete column. There are various ways you can deal with row data, like adding them and so forth, but this does not apply to column data.
But there are two ways I can think of how you can get your standard deviation:
You use an external program or export your data differently (that is if you have influence on the export algorithm
You use an external program like awk inside gnuplot. Some samples of this approach are described here.

Recompute a 3d vector field in a set of isosurfaces

I working on program (fortran90), which computes an magnetic field of some static set of wires with electric current. Its output is a magnetic field vectors in many points as file with columns "x,y,z,v_x,v_y,v_z). I able to plot this with gnuplot, e.g.:
But now I want to rewrite program to output isosurfaces (surfaces at which modulus of magnetic field vector is constant), like this (it is found in internet and don't correspond to first image)
Can I do this as second program or with using utility, which will convert my file with 6 columns into ... something format which can be drawn as surface set. Another way of doing this, as I think, is to rewrite first program to compute isosurface directly. Please, recommend me which way is better and how actually I can do this.
I think MathGL can do it easily. It is cross-platform GPL plotting library which have Fortran interface too. Here you can use a sequential call of vector fields and isosurface plotting.

Resources