I have a set of tubes representing boreholes in a vtp-file (written by vtkXMLPolyDataWriter). Now for clarity I would like to add text labels to identify the boreholes when displaying them in paraview.
My idea was to create labels with vtkTextActor3D, to convert these actors to polydata, and then output these labels, split into polygons, to a vtp-file with the polydatawriter.
How can I do this? In paraview I was able to create a 3D Text source and save it to a vtp-file. However, I can't figure out how to do this in python.
Thanks!
I think to do it the way you described you should actually use vtkVectorText instead of vtkTextActor3D, because accroding to the documentation for vtkTextActor3D, it works like this: The input text is rendered into a buffer, which in turn is used as a texture applied onto a quad (a vtkImageActor is used under the hood). So you actually don't get any geometry for individual characters of your text, instead you would have to save the texture and display that in paraview. Meanwhile, vtkVectorText should (I've never used it personally...) produce an actual geometry for your characters so you can save them as any other polydata.
Related
i want to create a plot with 13 different arrow styles for a vector field showing the stream of a sea. I want to use very specific arrows which are not bult in FancyArrowPatch. Is ther a possibility to use a selfmade design as arrow in python ? Is it possible to somehow add custom arrow styles to the FancyArrowPatch function ?
I have attached the image I want to reproduce with Python (taken from bsh.de/DE/DATEN/Stroemungen/stroemungen_node.html):
My best try was to produce this one:
Which is not quite satisfying yet. I would like to have the same arrows as seen in the first image. If you have suggestions how to make the image fancier I am open for that too.
I want to define an rectangular area on top of an image, that has got a specific width and a specific height and in which a text should be pasted. I want the text to stay inside of this text field. If the text is longer, its size should be decreased and at one point it should be converted into a multiline text. How can I define such a text field using Pillow in python3?
I am looking for a clean and minimalist solution.
Sadly, I have no idea how to do this, since I am very new to python. I also didn't find any helpful and fitting information on how to do this, in the Internet. Thanks in advance!
How do I add circle-clipped image glyphs to my chart, without processing and uploading the images manually beforehand? I'm open to using other modules.
I want the end result to look something like this chart (from nytimes).
http://imgur.com/a/Nv6ta
My current understanding is that we can only load images directly from urls, which is not my desired outcome.
http://docs.bokeh.org/en/latest/docs/reference/models/glyphs/image_url.html
My current understanding is that we can only load images directly from urls
This is not correct, there is also ImageRGBA which allows for sending images as raw RGBA data, directly embedded in the Bokeh document. See, e.g., this gallery example:
http://docs.bokeh.org/en/latest/docs/gallery/image_rgba.html
So assuming that images is a Python list of 2D NumPy arrays of RGBA data for the (pre-cropped) images you want to display, then Bokeh could show them with:
p.image_rgba(image=images, x=....)
Of course, you have to convert the images to RGBA arrays yourself, and also crop them, so things may simply be easier or more ready made for this use-case with another tool.
In various cases whenever I use latex in matplotlib, I am getting a very pixely appearance when rendering the figure to an image. When I view the figure in interactive mode it looks fine. For example, I'm setting the yaxis label with:
'Emissions Flux '+r'($\mathregular{(\mu g/m^2 s)}$'
I'm also setting the twin y axis to a log scale and the eponents are presumably latex as well. Non latex text is crisp.
I as far I understand the problem your images are too pixelated. Often this is the result of saving an image using a bitmap format. To receive better images one should export them to vector-graphs, like for example pdf.
To export images as vector-graphs your save statement should be something like:
myfig.savefig('myfig.pdf', format='pdf')
A clear explanation about bitmaps and vector graphs: http://www.prepressure.com,
an important source of information concerning matlibplot: http://matplotlib.org
I have to build some rudimentary CAD Tool in Python based on matplotlib for handling the display of the content.
After all the parts have been put together, the whole layout shall be exported as line elements (basically just tuples of the start / end coordinates of the lines, e.g. [x1,y1,x2,y2]) and just points.
So far I have all the basic gemoetric stuff implemented, but I cannot figure out how to implement text properly. To be able to use different fonts etc. I want to use the text capabilities of matplotlib, but I can't find a way to export the text properly from matplotlib.
Is there a way to get a vectorized output right away? Or at least an array of the plotted text?
After some days of struggling, I found a way to get the outline of the text: https://github.com/rougier/freetype-py , more precisely the example https://github.com/rougier/freetype-py/blob/master/examples/glyph-vector.py
If you just want to get the outline as an vector array, you can delete everything after line 78 and do this:
path = Path(VERTS, CODES)
outline = path.to_polygons()
This will give you an array of polygons, and each polygon is again an array of points (x,y) of the polygon.
Though it was some trouble to get freetype running on windows and I still have not figured out how to make it portable, I think I will stick with this solution, because it is fast, reliable and allows one to use all the nice system fonts.