I have a set of incomplete 3D data. The data looks like the following:
X Y Z
1 1 3
1 2 4
1 3 5
2 2 8
2 3 7
2 4 1
3 1 0
3 4 3
Kindly note that the data is incomplete, since the data points with (1,4), (2,1), (3,2) and (3,3) is missing if I consider my X range as (1,2,3) and Y range as (1,2,3,4). Due to scientific reasons, the data is those points cannot be estimated.
As a result the data cannot be made to a grid which is required by most of the programs for 3D plotting. However, I need to go for a contour plot of the same.
Hence, can you kindly let me know of any software which will enable me to do the same, and also how to get it done? I would personally prefer a contour plot with colours. I do not mind leaving empty boxes in the plot, since my data is incomplete.
Mathematica
data = {
{1, 1, 3}, {1, 2, 4}, {1, 3, 5},
{2, 2, 8}, {2, 3, 7}, {2, 4, 1},
{3, 1, 0}, {3, 4, 3}
};
ListContourPlot[data]
Related
Given a graph, I want to find all the subgraphs that only has 1 input edge and 1 output edge. For example, in this graph, the subgraphs will be [1, 2, 3, 4], [5, 6, 7, 8]. I don't know how to describe this problem in a formal way so just putting a graph here.
Edit:
Thanks to the comment. The subgraphs shouldn't overlap with each other. Fro example, I don't want [2, 3] since it is part of [1, 2, 3, 4].
I am looking for an efficient algorithm (if there is one) to solve the following problem:
Given a set S, whose elements are sets with only two elements. For simplicity, let' s say "two elements" are integers from 1 on. As an example, S can be decribed like: S = {{1, 2}, {2, 3}}. We define R as a radix, which means the integers in the set can not be greater than or equal to R, a bit different from integer 10 in the decimalism. We now define a group G which is merged by the disjoint sets in S with the total count of integers in G less than or equal to R. For example, S = {{1, 2}, {1, 3}, {1, 4}, {2, 3}, {2, 4}, {3, 4}}, R = 4, and then G1 = {{1, 2}, {3, 4}}, G2 = {{1, 3}, {2, 4}}, G3 = {{1, 4}, {2, 3}}. Therefore, in this example, the minimal count of groups is 3.
I want to know if there is any algorithms can efficiently solve this problem with minimal groups. Before posting this problem, I was thinking to transform it into a graph clustering problems, however I find it hard to do with it. I hope I can get some help here, thank you!
I think I must have misunderstood this question, it seems so trivial.
Let
N be the number of sets in S
M be the minimal number of groups in G1, G2, ... GM
then
M = ( 2 * N ) / R, rounded UP to the nearest whole integer
The rounding up is needed because if 2 * N is not divisible by R, then there will one G group with less than R elements.
e.g for your example: M = 2 * 6 / 4 = 3
I'm given a dictionary with keys(ids) and values.
> Dict{Int64, Vector{Float64}} with 122 entries:
3828 => [1, 2, 3, 4...
2672 => [6,7,5,8...
...
Now I need to apply umap on it. I have the code that
embedding = umap(mat, 2; n_neighbors=15, min_dist=0.001, n_epochs=200)
println(size(embedding))
Plots.scatter(embedding[1,:],embedding[2,:])
Here mat is the matrix
1, 2, 3, 4
6, 7, 5, 8
....
So I got the embedding matrix and the umap plot. But in the plot all points are same color and no labels. How do I do so that I can get points with labels(keys in the dictionary)?
Looking at UMAP.jl, the input matrix should have the shape (n_features x n_samples). If each entry in your dictionary is a sample and I’m interpreting your matrix notation correctly, it appears you have this reversed.
You should be able to add the keys of the dictionary as annotations to the plot as follows (potentially with an optional additional offset to each coordinate):
Plots.annotate!(
embedding[1,:] .+ x_offset,
embedding[2,:] .+ y_offset,
string.(collect(keys(yourdict)))
)
Finally, I’m not sure what variable you actually want to map to the color of the markers in the scatterplot. If it’s the integer value of the keys you should pass this to the scatter function just like above except without turning them into strings.
I would like to connect points on a cartesian coordinates system, like the image below:
x = 1:10;
y = rand(10);
plot(x, y)
In the image above these points are random and the x axis can only take the values from 1 to 10.
I want to create a similar plot where I can assign the position of specific points ( let us name these points: [x_i, y_i] ) and connect them. Here is an example of some values for [x_i, y_i]
[0,2], [4,-10], [5, 12], [12, 6]
From the docs:
you can plot a line by calling plot on two vectors of numbers.
You can pass as first argument to plot a vector of the x_is, and a vector of the y_is as the second argument. Then plot will draw a line. For example:
plot([0, 4, 5, 12], [2, -10, 12, 6])
If you must take the input as pairs of [x_i, y_i], you can just do a little preprocessing before you plot. E.g.
input = [[0,2], [4,-10], [5,12], [12,6]]
4-element Vector{Vector{Int64}}:
[0, 2]
[4, -10]
[5, 12]
[12, 6]
plot([x for (x, y) in input], [y for (x, y) in input])
Both produce the output:
I am trying to create some basic animations for a set of RGB LEDs. Normal linear animations are simple enough using loops and counters to vary the light colour.
What I have is a ring of 24 LEDs and want to be able to apply animations to them so that the effect, say a simple colour wipe, occurs from top to bottom, or side to side (basically any given direction).
I have not made any progress worth sharing, other than storing an array of each "row" of LEDs:
0 => 0
1 => 1, 23
2 => 2, 22
3 => 3, 21
and so on
This is a crude solution, and I am hoping there are better ways using cos/tan perhaps.
My question is how to address each LED in sequence when performing an animation from top to bottom (or starting at any n degrees).
Trigonometry is relevant if you want to go from a single number (an angle) to a pair of numbers (coordinates of a point on a circle). Your LED addresses seem to be single numbers in the range 0 to 23. They essentially are angles (one every 360/24 = 15 degrees, so you don't need an angle to coordinate conversion.
What you do need is a way to model rotational symmetry, but that is simply modular arithmetic (working mod 24). To give some idea, here is a Python script which could be used to "wipe" from any of the 24 points:
def wipe_from(i):
leds = [[i]]
for j in range(1,12):
leds.append([(i+j) % 24, (i-j) % 24])
leds.append([(i+12)%24])
return leds
For example, wipe_from(0) corresponds to what you already have, and wipe_from(5) is:
[[5], [6, 4], [7, 3], [8, 2], [9, 1], [10, 0], [11, 23], [12, 22], [13, 21], [14, 20], [15, 19], [16, 18], [17]]