Natural combination between Python and TeX [closed] - python

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
As a graduate, I often plot various kind of figures and have found many plotting software.
I appreciate the high quality drawings in TeX, using tools like Asymptote and Tikz. As a poor programmer, I also need the flexibility brought by Python when I need do some complex calculations during plotting. The combination from both side, which I deeply believe, will be a perfect choice.
So, is there any chance for me to find some software like this, with both Simple and Beatiful in mind.

There are several python libraries which excel at various types of graphics such as MayaVi.
Here is an example of simple TeX integration with matplotlib in python (not showing all the math stuff, but just the plotting code:
figure(2)
plot(x,Ni[:,1], 'b.', x, y, 'r.', x, z, 'g.', markersize=10)
xlabel('nm')
ylabel('Sulfur normalized intensity')
legend(['Ni/S', r'exp profile $\tau$ = 200 nm', r'exp profile $\tau$ = 98 nm'], loc='best', numpoints=1)
pylab.subplots_adjust(bottom=0.15, left=0.15)
show()
which produces:
Notice the tau is actually just a snippet of TeX embedded into the image. Most of the matplotlib commands allow this so you can draw equations into your image or whatever you want to do.

Related

Calculating overlap of polygons using Python, unsure of which package to use [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed last month.
Improve this question
I am relatively new to Python generally and GIS specifically and wondered if I could get some advice on the best package to use to calculate the overlap of two polygons I have calculated and stored in GeoJson format.
Basically, I have two lists, one is a few large polygons and the other is a lot of small polygons. I would like to know for each of the large polygons which of the smaller ones are wholly or partially within the large one, storing the percentage of the smaller polygon contained in each case.
From an Udemy course I have completed, I think that GeoPandas might be suitable but would it be better to just use Shapely, given I have the GeoJson of the two polygons I wish to check, or is there a better package?
Thanks in advance.
if you have your data in geojsons or geopandas dataframes, this is the easiest way to do it:
import geopandas as gp
import matplotlib.pyplot as plt
gdf1 = gp.read_file(jsonfile) #one set of polygons
gdf2 = gp.read_file(otherjsonfile) #another set of polygons
gdf3 = gdf1.intersection(gdf2) #this calculates the intersection between all shapes in gdf1 and gdf2
gdf1.plot(ax=ax, color='r', alpha=0.5):
gdf2.plot(ax=ax, color='b', alpha=0.5):
and now, the intersection..
gdf3.plot(ax=ax, color='g', alpha=0.5)

What toolkit in Python can achieve the effect as shown in the figure [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 1 year ago.
Improve this question
I'd like to draw a three-dimensional trajectory that can show the attitude of the plane as shown in the figure. What toolkit in Python I should learn?
What you are looking for is 3D Line plots of Matplotlib.
To help you get started, you can refer to this Blog: An easy introduction to 3D plotting with Matplotlib
The official Tutorial of matplotlib 3D Plots can be found here: Matplotlib 3D Tutorial - Lines
If you want to explore more, a very good resource to different types of Graph Plots along with code examples can be found here: Python Graph Gallery
the standard plotting library in python (pretty much) is Matplotlib. It contains a 3D API called mplot3d.
For an example, see here: https://matplotlib.org/stable/gallery/mplot3d/scatter3d.html
The example you are showing does look a lot like it was created with Matplotlib. Other options include seaborn and bokeh. Your choice what to use, really.

How can I visualize a 3D volume with Python? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 1 year ago.
Improve this question
Similar to how there's vol3d for Matlab, how can I visualize a 3D-Array in Python? I'm currently working with Matplotlib but I'll take whatever works.
Mayavi has some good API for 3D plotting in python
I strongly recommend K3D:
K3D lets you create 3D plots backed by WebGL with high-level API
(surfaces, isosurfaces, voxels, mesh, cloud points, vtk objects,
volume renderer, colormaps, etc). The primary aim of K3D-jupyter is to
be easy for use as stand alone package like matplotlib, but also to
allow interoperation with existing libraries as VTK.
It works best in Jupyter Notebook.
You are probably looking for mplot3d plot_surface, which is part of matplotlib. Examples are provided in the link.

Animation of xy data in matplotlib [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
So essentially I have a few numbered files like output_0000.dat ... output_1999.dat that each correspond to a consecutive timestep in the simulation of a wave on a string. The files contain the x and y positions for each point on the string at that timestep.
My goal is to plot these files one after another to make an animation, ideally using matplotlib but other software will also do.
If you could also direct me to a helpful tutorial, I'll be very greatful.
Thanks!
The animation tutorial suggested by #tom are probably the ideal solution, however the simplest way to do what you want is to use interactive plotting with filenames padded by zeros and numpy's genfromtxt,
import numpy as np
import matplotlib.pyplot as plt
plt.ion()
plt.show()
for i in range(2000):
filename = "output_{0:04d}.dat".format(i)
print("printing file = ", filename)
xy = np.genfromtxt(filename)
x = xy[:,0]; y = xy[:,1]
plt.plot(x,y)
plt.pause(0.01)
You may need to add delimiter to genfromtxt depending on the format of the data in your files.

Python plotting libraries [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
Improve this question
What alternatives are there to pylab for plotting in Python? In particular, I'm looking for something that doesn't use the stateful model that pylab does.
Plotly lets you make graphs using a Python API, matplotlib, and pandas. Their IPython gallery has some example scientific graphs with the Python scripts that generated them.
Here's a sample:
Some recent exciting open source offerings:
ggplot is based on R's ggplot2, with aesthetically pleasing defaults and a really concise api. wants to be a matplotlib killer
bokeh makes interactive (html canvas) plots. emphasis on interativity + handling big data
vega translates JSON "plot descriptions" into SVG or Canvas-based interactive plots, and vincent is a declarative interface for generating the JSON specifications.
(source: fastly.net)
There is a list of Python-based plotting tools on the Python wiki.
You can always use the object-oriented framework for Matplotlib instead of the pylab interface.
I have used Gnuplot.py with great success.
I was in need of gnuplot interface for Python 3 but have found nothing. So I have ported Gnuplot.py to it.
See more info in the 'readme' of the [repository]. Hope this will help someone else in future.
There is also a old program for automating the reading, filtering, processing, interpolation and plot n-dimensional values from different sources (like libreOffice- or csv-files) and variable size:
diaGrabber.
You have to use some simple python-commands to create a case. After this you can manipulate the graphical output in an interactive GUI.
You can use simple gplot
MathGL is free (GPL) plotting library with large set of graphics types, and have Python interface too (also can use numpy arrays).

Categories