How to export view to a vector image format in Netlogo - netlogo

I would like to export the exact view of agents layout (including their shapes and colors) into a vector image file format such as EPS, PDF, SVG,...
Is there any way to do that without vectorizing the generated PNG files with another application?
EDIT 1:
I tried to write an extension as Seth recommended, but the generated image is as follows:
Generated Image of the extension
EDIT 2:
The problem was with the vector library I was using. Changing the library, the extension works like a charm!

A new extension is built to export the view of model to a vector image file. The supported formats are EPS, PDF, and SVG.
You can find the source and the built files here:
https://github.com/aesmaeili/vectorview

Great question! Sadly no, this is not supported in stock NetLogo. It should be; I wish it were!
SVG would be an excellent choice of output format.
Someone with some knowledge of Java or Scala coding could write a NetLogo extension that does this, by recording the Java2D calls that the NetLogo renderer makes, using a library such as https://xmlgraphics.apache.org/batik/using/svg-generator.html.

Related

How to visual a 3D bathymetry data in Paraview

I want to display a 3D bathymetry data in paraview, the file datatype is netcdf:
it has two dimensions and three variables;
my netcdf file format
When I try to open it in paraview: it is a 2D not 3D,
2D
I want to display Dlike this:
3D
i’m sorry for bad English and less infomation.
The most simple way to do that is to use the Extrusion Surface representation.
https://blog.kitware.com/a-new-embossing-representations-plugin-for-paraview/
Open ParaView
Tools -> Manage Plugins -> Embossing Representations
Create a new view
Open your file
Switch representation to Extrusion Surface
Only Available since ParaView 5.6.0. Keep in mind this is only a representation, not a change to the actual data. If you want to change the data, you will have to use CellDataToPointData and WarpByScalar, which will require more tweaking.

Is EPS image editable

I converted a matlab fig to eps, I need to add the grid to this figure which now I have in eps format. Is there any possibility. I know I can change the title or labels using ultraedit or similar programs but cant identify the relevant place for grid.
Yes, you simply need to read the PostScript program and then modify it to be suitable for your needs.
You will, however, probably need a working knowledge of the PostScript language in order to understand the program and succesfully modify it.

iPython nbconvert and latex: use .eps instead of .png for plots

I have an iPython notebook that contains an inline plot (i.e. it contains the command plot(x,y)). When I issue the command ipython nbconvert --to latex --post PDF --SphinxTransformer.author='Myself' MyNotebook.ipynb the resulting .PDF file contains the figure, but it has been exported to .PNG, so it doesn't look very good (pixelated). How can I tell nbconvert to export all plots/figures to .EPS instead?
Thank you
First of all the notebook is not responsible for creating plots, but matplotlib and this allows to render your plots as eps, pdf, svg, etc. in great quality to be included in publications.
I agree that the default inline plot format, i.e. png is not optimal to be used for publications due to several reasons. As given in the github issue you posted in your answer, the inline backend can be configured to use svg instead of png by calling
%config InlineBackend.figure_format = 'svg'
in a code cell.
With this, the newly created plots will be vectorial, (as Matt said, already rendered pngs will not be converted!). These svgs are embedded in the notebook (svgs can be rendered by modern browsers) and are subsequently converted to pdfs by nbconvert. These pdfs fulfil the requirements of publication ready plots. However, be aware that the svgs can be really huge (compared with pngs) and may slow down the notebook handling significantly.
Your initial question was about eps graphics. As said above, matplotlib can render eps, hence, you can always do something like savefig('plot1.eps') to create the desired figures. That's actually the way I create my publication figures (png in notebook, eps in paper).
Let's assume we would get IPython to generate eps files (embedded but not renderable in the browser). The tex file generated by nbconvert is designed to work with pdflatex. If fed with eps files pdflatex would convert these to pdf to be included in the final document. So basically it does the same as nbconvert currently does with the svgs. Thus, there is no benefit.
Finally, I want to point out that, even though the tex files generated by nbconvert look great (especially the ones created using the master branch), IMHO there is no way to use these files without touching (e.g. adding captions, scaling images, ...). Therefore, you could always include the eps files at this step into your papers.
NBconvert does not run your code. So if you haven't plotted with SVG matplotlib backend it is not possible.
If you did so, then you need to write a nbconvert preprocessor that does svg-> eps and extend the relevant template to know how to embed EPS.
Evidently this is a missing feature in nbconvert. There is not currently a way to get publication quality plots in your final PDF: https://github.com/ipython/ipython/issues/3603
https://github.com/ipython/ipython/issues/3693

Add text to PDF

I've got an exported version of a MATLAB diagram, similar to the one below. The problem is, that there are no axis captions. It's not possible to export the file again from MATLAB. I need to edit the PDF programmatically and edit about 100 diagrams, all with the same axis positions.
Is there a clean and fast way to paste the Strings X and Y at the corresponding positions in the pdf based on a batch process?
Create a PDF file with the captions. Add that as a background with to the PDF files with pdftk.
if know how to use LaTeX, the pstool package can bring you far on this on, including replacing labels (or actually any text on an eps figure) with TeX symbolic expressions. Neat if you're already working in LaTeX.

Setting DPI for PNG files

I have a bunch of diagrams created using a Java diagramming tool that I wrote - they are mostly black and white diagrams, with the blocks in aqua, and occasional other colours. They are currently being saved as JPG files, and I want to insert them into a book that I am preparing for Print On Demand.
The book is an OpenOffice ODT file, which will later be converted to a PDF.
Currently I use JPG files, but the print facility they use requires 300 DPI, so I modified my diagramming tool to set the xDensity and yDensity to 300, and resUnits to 1, using getAsTree(), and then expand the diagram by a factor of 3 (300/96). IMO the result looks pretty good!
Unfortunately, someone on another forum pointed out that line diagrams are "fuzzed" on JPG files, so suggested that I change over to PNG, or possibly BMP files, both of which ODT files allow to be inserted.
My problem is that BMPs don't seem to have a DPI, and PNGMetadata doesn't seem to support getAsTree(). Can someone point me in the right direction? Thanks.
I don't understand the getAsTree() part, but answering the question that appears in the title, setting dpi for PNG files, you could use the imagemagick convert tool:
convert -density 300 -units pixelsperinch infile.jpg outfile.png
PNG, BMP and dozens of other image formats don't compress your diagrams - compression is probably what your commentor was getting at. JPEGs are great for photos but suck at diagrams.
You might want to look into SVG and other vector formats. Or if your environment allows, exporting 0% compression JPEGs and converting them into another format for lossless reproduction at 300DPI.
Hope that helps!
I decided not to try to do this programmatically. Instead I create the original diagram in PNG, then convert to 300 DPI using Irfanview. Irfanview's batch capability lets me convert to 300 DPI, scale up to compensate, and set to grey scale, all in one operation - and on multiple files at a time. This seems to be the best solution - but thanks to everyone anyway!