Home > Back-end >  Plotting position coordinates in Python
Plotting position coordinates in Python

Time:03-11

I need to draw a track in a coordinate system (i.e. a 400m running arena), and then plot real-world position data (taken at a similiar track) from a Kalman-filter into this coordinate plot. Any ideas on what type of libraries/plotting methods will be best to solve the plotting part? And how to draw this track from scratch? I am pretty new to Python. Thanks in advance!

CodePudding user response:

You can use folium to plot Map. To draw track, you could use Polyline. Folium can plot polyline object

Here is a example:

m = folium.Map(location=[45.372, -121.6972], zoom_start=12, tiles="Stamen Terrain")

tooltip = "Click me!"

folium.Marker(
    [45.3288, -121.6625], popup="<i>Mt. Hood Meadows</i>", tooltip=tooltip
).add_to(m)
folium.Marker(
    [45.3311, -121.7113], popup="<b>Timberline Lodge</b>", tooltip=tooltip
).add_to(m)

m

CodePudding user response:

i would suggest as you already included in your tags to use matplotlib. It is fairly easy to understand and there is a lot of free resources to learn.

My approach would be to include image of the track into the plot, and then sacle both axis accordingly. Then you should be good to go by simply using plt.plot(datax, datay) to plot it onto the graph.

Here would be a short example to get started:

import matplotlib.pyplot as plt
import matplotlib.image as mpimg

img = mpimg.imread('test.jpg')
imgplot = plt.imshow(img)
ax = plt.gca()
ax.set(xlim=(0, 400), ylim=(0,400))
ax.plot([i for i in range(400)], [j for j in range(400)])
plt.show()
  • Related