I'm trying to visualize frequency of imported from reports items in array using Python. I'm new to drawing graphs, so how to do it, using any module?
To draw graphs in python you need to do the following,
import matplotlib as plt
plt.plot(array_1,array_2)
plt.show()
I highly recommend checking out this Matplotlib Docs
After looking at various related answers, I could not figure out a straight way.
I have a 3-d numpy array of shape (390, 280, 160). I want to visualize this as an image. What could be the simplest way to do it?
Here is a minimal example of volumetric plot using mayavi.
You can find more examples of 3d data visualization here
from mayavi import mlab
import numpy as np
s = np.random.rand(20, 20, 20)
volume = mlab.pipeline.volume(mlab.pipeline.scalar_field(s), vmin=0, vmax=0.8)
mlab.draw()
mlab.savefig('output.png')
From mayavi docs
For such a visualization, tweaking the opacity transfer function is
critical to achieve a good effect. Typically, it can be useful to
limit the lower and upper values to the 20 and 80 percentiles of the
data, in order to have a reasonable fraction of the volume
transparent.
I'm looking for a way to use matplotlib's 3D plotting
capabilities to display a flat image (a png or tiff) in 3D
space for some visualization I'd like to do.
The documentation is not very helpful,
is this even possible?
Here's a post that shows how to do what you're looking for.
Image overlay in 3d plot using python
Is it possible to annotate a pyplot figure, but not with text or circles or the other similar objects, but an image instead?
For example read a png from a file and present it below a plotted data in the same graph.
This demo seems to do what you're looking for. Below is the the resulting plot:
I want to plot some (x,y) points on the same graph and I don't need any special features at all short of support for polar coordinates which would be nice but not necessary. It's mostly for visualizing my data. Is there a simple way to do this? Matplotlib seems like way more than I need right now. Are there any more basic modules available? What do You recommend?
Go with matplotlib Chance is that sometime in the future you might need to do more than just "simple" stuff and then you don't need to invest time learning a new plot-tool.
See this link for list of plotting tools for python...
Absolutely. Matplotlib is the way to go.
The pyplot module provides a nice interface to get simple plots up and running fast, especially if you are familiar with MatLab's plotting environment. Here is a simple example using pyplot:
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(111)
x_points = xrange(0,9)
y_points = xrange(0,9)
p = ax.plot(x_points, y_points, 'b')
ax.set_xlabel('x-points')
ax.set_ylabel('y-points')
ax.set_title('Simple XY point plot')
fig.show()
import matplotlib.pyplot as plt
x = range(1,10)
y = range(1,10)
plt.plot(x,y,'o')
plt.show()
Here's a simple line with made up x, y. Note: x and y are lists.
Their lengths should be equal or you'll get a error. Cheers!
I suggest the most good looking plotting library for Python: CairoPlot
You can use the Tkinter canvas widget. It uses rectangular coordinates but of course you can translate to polar. The canvas is pretty much just like it sounds -- a blank canvas on which you can draw points, lines, circles, rectangles, etc.
You could always write a plotting function that uses the turtle module from the standard library.
MathGL is GPL plotting library which have Python interface, arbitrary (including polar) curved coordinates, a lot of plot types, export to PNG, EPS, SVG, widgets, and so on. For 1D plot samples see here.
Have you tried to use pillow?
from PIL import Image, ImageDraw
#Set up canvas
img = Image.new (mode, size)
draw = ImageDraw.Draw (img)
#Draw your points
draw.point (xy, colour)