Skip to content

Commit

Permalink
Update on matplotlib map marker color
Browse files Browse the repository at this point in the history
  • Loading branch information
JerelHJ committed Feb 3, 2024
1 parent 8d52b4d commit 8ca8682
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 7 deletions.
Binary file modified Images/Individual_Plots/plot_SecGuardID_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed Images/Individual_Plots/plot_SecGuardID_2.png
Binary file not shown.
Binary file removed Images/plot_SecGuardID_1.png
Binary file not shown.
Binary file removed Images/plot_SecGuardID_2.png
Binary file not shown.
25 changes: 18 additions & 7 deletions python/seer2.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,28 @@ def image_spoof(self, tile):
# Add the spoofed OSM image to the map with the specified zoom level
ax1.add_image(osm_img, int(scale + 1))


# Define a colormap based on the number of unique floors
floor_colormap = plt.cm.get_cmap('viridis', len(secguard_df['Floor'].unique()))

for index in range(0, len(secguard_df['Longitude']), 5):
floor_color = floor_colormap(secguard_df['Floor'].iloc[index] / len(secguard_df['Floor'].unique()))
ax1.plot(secguard_df['Longitude'].iloc[index], secguard_df['Latitude'].iloc[index], markersize=10,
marker='o', linestyle='', color='Black', transform=ccrs.PlateCarree(), label='GPS Point') # plot points
marker='o', linestyle='', color=floor_color, transform=ccrs.PlateCarree(), label='GPS Point')

plt.pause(1)


# Create a legend
handles = []
labels = []

annotation_text = f'Alt: {secguard_df["Altitude"].iloc[index]:.2f} meters\nFloor: {secguard_df["Floor"].iloc[index]}'
ax1.text(secguard_df['Longitude'].iloc[index], secguard_df['Latitude'].iloc[index], annotation_text,
fontsize=10, color='red', transform=ccrs.PlateCarree(), ha='right', va='bottom')
for floor in secguard_df['Floor'].unique():
floor_color = floor_colormap(floor / len(secguard_df['Floor'].unique()))
handles.append(plt.Line2D([0], [0], marker='o', color=floor_color, label=f'Floor {floor}', markersize=10, markerfacecolor=floor_color))

plt.pause(0.1)
else:
print(f"Error: No data for SecGuardID {secguard}")
labels.append('Floors')
ax1.legend(handles=handles, labels=labels, loc='upper left', bbox_to_anchor=(1, 1), title='Legend', fontsize=10)

# Save individual plots
plt.savefig(f'{individual_plots_directory}/plot_SecGuardID_{secguard}.png')
Expand Down

0 comments on commit 8ca8682

Please sign in to comment.