short: I want to connect dots that are close to each other in a 3D scatter plot with lines to get some "3D wired look" 3D model.
Background: I got from a microscope an image stack from a fish. I want to show specific cells in that fish. The Software gives me X, Y, Z values of these cells and I'm plotting them in a scatter 3D plot. To get an context I collected a lot of values (XYZ) from the skin too and want to plot them "around" the whole thing to get the look of an fish. If I would be able to connect these dots with lines Id get some kind of "wired" fish which would be great. It would be even greater if id be able to fill the planes in the wire (that would be a 3D fish).
#data of the cells
X = np.array(df["X"])
Y = np.array(df["Y"])
Z = np.array(df["Z"])
#data of the fishskin
XF = np.array(df["XF"])
YF = np.array(df["YF"])
ZF = np.array(df["ZF"])
ax.scatter(XF, YF, ZF, s=40, c='b', marker='o')
ax.scatter(XV, YV, ZV, s=40, c='r', marker='o')
plt.show()
that's what I did so far, very basic but hey, I'm rookie.
The only language I'm a little into is Python but I also got MatLab and toyed around with Blender a little. If you think my problem would be a lot easier to solve in one of these programs (maybe model the fish in blender end import him to Python or whatever) tell me! I was searching around the whole day but maybe I'm using the wrong keywords or something because I wasn't successful.
If I understand your question correctly, you would like to create an unstructured triangular grid. If this is the case, then I suggest you check out this tutorial on the Matplotlib website.
Related
360 degree rotation 2d stack of images of a pencil (side view)
Hey guys, I had to create an account on stack-overflow just to post this because I could not find anything close to what I'm trying to replicate on here (maybe I havent looked in the right place idk). I am currently doing a project wherein I have to find the CT reconstruction of a stack of images taken via X-ray imaging. I have downloaded Fiji (ImageJ) to try and process the images but they end up not turning out right so I decided to try and write an algorithm to see if I can get anywhere. I have started by simply doing 4 times 90 degree rotations instead of trying to do the full 360 degrees first. I have found nothing online that would help with what I'm trying to achieve but let me know If I've been looking in the wrong place. Also if there is any other information that you need me to provide let me know. After being able to get the top view slices I'm quite certain of knowing how to be able to create the filtered back projection and the sinograms required to get the full CT reconstruction but this is the one step I am stuck on.
This is what I have so far:
imagestack = [image for image in os.listdir() if image.startswith("image")]
images = [plt.imread(image) for image in imagestack] #reading in the images using plt.imread
plt.figure()
plt.imshow(images[0], cmap='Greys')
plt.show()
plt.figure()
plt.imshow(images[89], cmap='Greys')
plt.show()
plt.figure()
plt.imshow(images[179], cmap='Greys')
plt.show()
plt.figure()
plt.imshow(images[269], cmap='Greys')
plt.show()
plt.figure()
plt.plot(images[0][:,255])
plt.plot(images[89][:,255])
plt.plot(images[179][:,255])
plt.plot(images[269][:,255])
plt.show()
#this plot shows the intensity of the pixels at different points of the images.
I am running this code on a Jupyter cloud which doesn't support a lot of external libraries so I am quite limited in what I can import into the notebook. I have come up with the idea of trying to find the z and x coordinates of the images where the middle of the pencil align, then I could try to find the y-coordinates from the obtained coordinates to create an approximate top view image from those.
Hi im new to python here.
I am trying to plot a line and a circle on the same graph to see if they intersect based on the user's input. This is what I have currently. I am not very familiar with matplotlib and after socuring through the internet for hours I am unable to combine the graphs properly. Can anyone help me.
Thanks a lot
Code and plot
I tried using the extend function as well as combine but to no avail
To plot several items in one graph, you can simply do:
plt.figure()
plt.plot(x1, y1)
plt.plot(x2, y2)
plt.show
Both curve will appear on the same figure.
Also, please put code rather than image so it's easier to replicate.
My program can generate up to 2000000 points within 5 seconds, so I don't have a problem with speed. Right now I am using matplotlib.pyplot.scatter to scatter all my points on my graph. For s=1, it gives me small circles, but not small enough, because it does not show the intricate patterns. When I use s=0.1, it gives me this weird marker shape:
Which makes the marker larger despite me making the size smaller. I have searched all over the internet including stack overflow, but they do not tell how to minimize the size further. Unfortunately, I have to show all the points, and cannot just show a random sample of them.
I have come to the conclusion that matplotlib is made for a small sample of points and not meant for plotting millions of points. However, if it is possible to make the size smaller please let me know.
Anyway, for my points, I have all the x values in order in one array, and all the y values in order in another array. Could someone suggest a graphing package in python I could use to graph all the points in a way that the size would be very small since when I plot the points now it just becomes one big block of color instead of intricate designs forming in the shape as they should be.
Thanks for any help in advance!
EDIT: My code that I am using to scatter the points is:
plt.savefig(rootDir+"b"+str(Nvertices)+"_"+str(xscale)+"_"+str(yscale)+"_"+str(phi)+"_"+str(psi)+"_"+CurrentRun+"_color.png", dpi =600)
EDIT: I got my answer, I added linewidths = 0 and that significantly reduced the size of the points, giving me what I needed.
Perhaps you can try making the linewidths as 0 i.e., the line width of the marker edges. Notice the difference in the two plots below
fig, ax = plt.subplots(figsize=(6, 4))
plt.scatter(np.random.rand(100000), np.random.rand(100000), s=0.1)
fig, ax = plt.subplots(figsize=(6, 4))
plt.scatter(np.random.rand(100000), np.random.rand(100000), s=0.1, linewidths=0)
you can set the marker to a single pixel using marker=',' in your call to scatter.
See the markers documentation here
I have a dataset of wind directions and I am looking to create raw data plots as seen in the example below. I should mention that I know about rose diagrams and how to create them in Python. This is another way of looking at the data and is commonly brought up in texts about directional statistics.
The plot is similar to a polar histogram, in that raw data is collected into continuous bins. But there are stacked individual dots for each data point instead of a bar.
I have found a solution on the mathematica stackexchange, but I have no experience with that language: circular plot and circular histogram. The book I took the above image from also gives the R code for it, but I only know Python.
Below is the minimal code I have until now.
directions = np.random.randint(low=0, high=90, size=50)
# Setup plot
ax = plt.subplot(111, polar=True)
ax.set_theta_zero_location("N")
ax.grid(False)
plt.show()
As you can see I have not made much progress. Again, I can find code for polar bar plots and histograms, but not for this type of plot in Python. Any hints in the right directions are welcome.
I am trying to build a website. One part of the website needs that a graph is show based on user input. It will be built using Django.
I have checked out a few options, mpld3 proving to be at least better than the others. The graph is kind of animated(?) as the scatter plots appear after a pause. This is a feature which would be great if I could include it.
So while using mpld3, I faced two problems:
1. When I run the python script, I have an image as a background for the graph. This does not appear when I use mpld3 to render it to a webpage.
2. Only the final plots appear. Is there a way that I can show the points coming up on the graph one by one with pauses as it is supposed to?
Here is part of the code with the necessary details. In case there's any further detail, I'll be glad to provide it.
fig, ax = plt.subplots()
im = plt.imread('map_main.png')
implot = plt.imshow(im)
plt.axis([0, width, 0, height])
plt.ion()
for i in locations:
x, y = locations[i]
plt.scatter(x, y, c='b')
plt.pause(0.05)
locations contain a bunch of coordinates where the scatter points are supposed to show up.
Any help on what I should study next to achieve this would be great. Thanks.