I have a data time-series that I am animating with matplotlib, and I would like to add frames by a specific time interval (e.g. monthly) to subplots in a matplotlib figure, so that I can have better control over the axes, etc. The end goal is having a one-page series of images depicting the animation.
Images source
Is there a way of doing this?
If not, is there at least a way to force it to save the frames .eps for better quality when compiling them together to import into a latex document?
Update:
I found that you are able to pickle Basemap objects (also discussed on this SO question), and apparently as of matplotlib 13.01 figures are pickle-able (experimental). I suppose you could pickle the instance of each desired frame and then subsequently load them to subplots. I will post my result once I've had time to try this out.
Related
working with Matplotlib I have produced some resistivity cross sections of the soil, obtaining pictures like this:
Now I would like to display all those sections in 3D so as to visualise better the spatial distribution of resistivity in the field (i.e. a so-called fence diagram). I would also like to plot the 2D map of the site where those measurements were carried out at the base of my plot (say on the XY plane).
As far as I have seen this is not feasible (or at least not convenient) with Matplotlib in 3D hence I decided to switch to Mayavi.
My questions are:
is it feasible georeferenced rasters and then properly place them on the correct (vertical) planes (not necessarily parallel to the cartesian ones) with Mayavi? Does imshow() serves this purpose?
is it better to recreate the contours in Mayavi at the proper locations? If this is the case I did not find a function to create contours from unstructured data (the input images were created with tricontour/tricontourf in Matplotlib). I do not think interpolating over a structured grid in scipy would do, given the non convex domain.
Ok, answering my own question:
mesh = mlab.triangular_mesh
surf = mlab.pipeline.surface(mesh)
seems to do the job.
To be consistent with the previous work, the triangulation, duly masked, can be directly imported from Matplotlib.
I was recently doing some EDA on a data set.I created a boxplot, a countplot and a violinplot using seaborn and created an image using matplotlib.
But the result is not very easy on the eye and looks very congested.
Is this normal? Any way to make it better ?
This is the image of the notebook
The answer depends on your problem:)
In my opinion, the spacing is not the problem, the aspect ratio is. Your individual plots don't have enough height. So try to change te aspect ratio and see if you like it better. So change the first line to:
plt.Figure(figsize=(8, 12)
for example.
I use dlib for my project. Basically it detects car in video stream. I use fhog_object_detector of dlib. When do training, it's hard to draw all object with same aspect ratio with dlib imglab tool. I have to draw object in all images, and manually change the object size in created xml file. Am I doing the right way, or it has a better way to do that work? I know dlib have just release a good CNN object detector for multi scale object detection, but because my computer doesn't have a GPU, so I can't use that.
Hope some one have a problem like me, and have found a solution.
Draw all the boxes as accurately around each object as you can. You want to have a well annotated dataset. That is useful in and of itself. Then, when you load the data for training, adjust the aspect ratios of the loaded boxes in your code before training. That is also a good time to look for outliers like really small boxes or boxes with extreme aspect ratios as you would probably want to exclude them.
We have a pdf page which contains one or more figures which are two-dimensional plots of experimental results. The figures may or may not be embedded in text. Each plot has the x and y axis with their labels and unit measurements marked in the plot. Inside each figure are one or more plots, each with a different color.
How can we convert the plot into a table of corresponding x and y values (say for 100 points) ?
I have already tried WebPlotDigitizer but it works only when the input is a standalone picture of a plot.
What I think I'll have to do is extract the plots from the PDF and process it further. Now, I am not able to find a tool for doing that. I have attached a sample PDF from which the plots have to be extracted.
Note that the 2 plots in the last page of the PDF are images and can be extracted readily(I've found a couple of software for those).The other plots are not images and the software are not able to extract them.
Is there any open source software that can achieve that?
Plots in this PDF file you have provided are made with vector drawings, so the only way to extract them is to convert PDF into image (i.e. render pages). Try ImageMagick's convert command line, see this answer
As Photoshop is very well scriptable, it is actually possible to extract images from a PDF programmatically (as opposed to pages; see Photoshop JavaScript documentation).
Then you have the whole set of instruments to adjust the images, so that further processing (interpretation) is easier to accomplish.
I am working on some batch routines to manage large libraries of jpg files. I have a nice routine that will quickly downsize 4mb+ files down to 40kb+. Using CCR.Exif, I can determine if an image needs to be rotated. My problem is that I can't find any code to rotate the image before I save it. I really need to be able to do this without incurring the overhead of bringing the image to screen.
I'm using the built-in jpeg.pas; I found another library by Gabriel Corneanu at CodeCentral, but it hasn't been updated for DXE2. All I need to do is a 90° rotation.
Any help will be greatly appreciated!
JPGs are compressed and must be rendered before you can work with the image data. Even if it is a non-visible canvas, they still need to be loaded into a component that renders them. Then you can use Windows API calls to rotate the image by directly accessing the canvas. I haven't rotated the image before, but I have manipulated it in other ways by accessing the canvas.
GR32 and EFG are both good sites with several components and algorithms. Here is one example on EFG's site that rotates an image. The code is Delphi 3, but it should still work fine for image manipulation.
EFG Example with Source
TImage32 has a method to rotate the image 90 degrees as well. See TImage32.Bitmap.Rotate90. TImage32 is part of the GR32 library and has been updated for Delphi-XE2.
svn co https://graphics32.svn.sourceforge.net/svnroot/graphics32/trunk graphics32
Also see: GR32 Homepage
If you need to rotate JPEG in steps by 90 degree, then look for lossless transformations.
For example irfanview.com has a special plugin DLL for it, though it does not have public API, but maybe you can ask Irfan Author for it or reverse-engineer it with debugger and cff explorer.
a lot of discussion might by just googled, including discussion how it is implemented.
https://www.google.ru/search?client=opera&q=lossless+jpeg+rotation
Component catalogues have that like
http://www.torry.net/quicksearchd.php?String=jpeg+lossless&Title=No
That will not work with rotation finer than 90 degree steps, but for orthogonal turns keep searchign for lossless jpeg transformations.
The fastest way to rotate a JPEG image would be to write a new / alternate pixel pump for the JPEG decoder that reads and decodes the JPEG pixels left to right (x,y), and writes them to bitmap memory as (y,x) - that is, writing one pixel per scanline at the same offset, instead of the normal mode of writing one pixel per column on the same scanline.
Anything else will be making multiple passes over the bitmap data.