Excessing Maps in python matplotlib graps - python

I am making a Tkinter based application in python which tracks the movement of users and plot them on a graph.
now ploting the points on a graph is no biggie, but what i couldnt manage was to give the background image as a map
currently my progress for this particular feature is nothing but as follows.
import matplotlib.pylab as plt
a=[[],[]]
a[0]=[12.28384,12,23434]#100's of values extracted from some csv file
a[1]=[80.12332,80.13312]#consider a[0],a[1] as latitude,longitude respectively
plt.plot(a[0],a[1])
plt.show()

This answer explains how to embed a map in a Tkinter window and may help.
You could also look at this example that uses the GooMPy library to embed an interactive google map in a Tkinter window.

Related

Real time ploting with matplotlib and tkinter

I'm currently working on a project in Python and I need to plot some data in real time. I would like to make a GUI, thinking of using Tkinter library. I am using matplotlib for ploting.
The program has a for loop in main in which i call a function (lets call it A_func) that needs about 1 ms to 20 ms to preform (depends on curvefit problem). in every iteration of for loop (A_func calculation) i would like to "modify" my plot on GUI (I am ploting outputs of A_func)
In the code below i tried to simply present my code.
MAIN
# Some code
for ID in range(0, 3000):
[output_data1, output_data2, output_data3] = A_func(ID, input_data1, input_data2, input_data3)
# I would like to modify my plot (GUI)
# example: plot(output_data1, output_data2)
I'm a bit lost right now because I'm new to Python so any kind of help would be greatly appreciated
Matplotlib has some animation capabilities.
from matplotlib import pyplot as plt
import matplotlib.animation as animation
Look for examples in the doc's ( and with google )

how create an animation

i'm a beginner in python, i really don't know how create an animation. I have different plots and i want to create a short video that concatenate these plots.
import pandas as pd
import matplotlib.pyplot as plt
data=[[1,1,3],[1,2,1],[2,1,9],[2,2,0]]
a=pd.DataFrame(data)
a.columns=['x','y','value']
data2=[[1,1,5],[1,2,2],[2,1,1],[2,2,3]]
b=pd.DataFrame(data2)
b.columns=['x','y','value']
data3=[[1,1,15],[1,2,7],[2,1,4],[2,2,8]]
c=pd.DataFrame(data3)
c.columns=['x','y','value']
final=[a,b,c]
for i in range(0,len(final)):
fig, ax = plt.subplots()
plt.scatter(final[i]['x'],final[i]['y'],c=final[i]['value'],vmin=0, vmax=15,)
plt.colorbar()
Python isn't really the way to go for creating a video.
If you want to present your graph(s) in video format, screenshot them using Windows Button + Print Screen (PrtSc) on your keyboard. This will save a screenshot to your pictures folder. Then, use a video editor, such as Vegas or free options like WeVideo to put the screenshots into a video.
You can also use presentation software, like Prezi, for a more engaging experience.

Use mouse to explore data displayed in python using matplotlib.pyplot lib

How can I use the mouse to explore a plot or image displayed in python?
I would like to:
use markers (add/remove/manipulate)
sample the data values (at plot/image/mesh)
continue evaluating code lines in the console
I am currently using matplotlib.pyplot for the display and mpldatacursor for interaction. is there better way?
my system (get stuck and crash too often) is: win7, python 2.7.6, matplotlib 1.4.2, mpldatacursor 0.5

Python Plotting and displaying multiple objects in same GUI window

I have a 2 part question:
what is the best method for plotting data in Python? I only need to plot data in 2d.
I have a canvas GUI that I built using Tkinter's canvas function. It draws an 8x8 grid of rectangles and also has some code to allow you to scroll the window. (I've attached a picture).
Is it possible to include a plot in the same window as this canvas object? I need to be able to display plotted data and hopefully add buttons to my GUI that will allow me to update the plot during the run of the GUI.
Thanks in advance!
Matplotlib is the de-facto way to plot data with Python. It's really wonderful. It can also be embedded in Tk.

How can I duplicate this simple matlab plot functionality with mathplotlib?

Here is a simple matlab script to read a csv file, and generate a plot (with which I can zoom in with the mouse as I desire). I would like to see an example of how this is done in python and mathplotlib.
data = csvread('foo.csv'); % read csv data into vector 'data'
figure; % create figure
plot (data, 'b'); % plot the data in blue
In general, the examples in mathplotlib tutorials I've seen will create a static graph, but it's not interactively "zoomable". Would any python expert care to share an equivalent?
Thanks
import matplotlib.pyplot as plt
import numpy as np
arr=np.genfromtxt('foo.csv',delimiter=',')
plt.plot(arr[:,0],arr[:,1],'b-')
plt.show()
on this data (foo.csv):
1,2
2,4
3,9
produces
When you setup the matplotlibrc, one of the key parameters you need to set is the backend. Which backend you choose depends on your OS and installation.
For any typical OS there should be a backend that allows you to pan and zoom the plot interactively. (GtkAgg works on Ubuntu). The buttons highlighted in red allow you to pan and zoom, respectively.
Since you're familiar with Matlab, I'd suggest using the pylab interface to matplotlib - it mostly mimics Matlab's plotting. As unutbu says, the zoomability of the plot is determined by the backend you use, a separate issue.
from pylab import *
data = genfromtxt("file.csv")
plot(data, 'b')

Categories