aditya-me13 commited on
Commit
a1c79cb
·
1 Parent(s): b372a6c

Fix color theme support in interactive plots

Browse files

- Added complete colormap mapping for all COLOR_THEMES in interactive plots
- Fixed missing mappings for Oranges, Reds, Purples, Blues, Greens, RdYlBu, Spectral
- Interactive plots now support all 14 available color themes
- Ensures consistency between static and interactive plot color schemes

Files changed (1) hide show
  1. interactive_plot_generator.py +2 -63
interactive_plot_generator.py CHANGED
@@ -33,69 +33,8 @@ class InteractiveIndiaMapPlotter:
33
  self.india_map = self.india_map.to_crs(epsg=4326)
34
 
35
  except Exception as e:
36
- print(f" Test failed: {str(e)}")
37
-
38
- def test_color_themes():
39
- """Test all available color themes for compatibility"""
40
- from constants import COLOR_THEMES
41
-
42
- # Create colormap mapping
43
- colormap_mapping = {
44
- # Sequential color schemes
45
- 'viridis': 'Viridis',
46
- 'plasma': 'Plasma',
47
- 'inferno': 'Inferno',
48
- 'magma': 'Magma',
49
- 'cividis': 'Cividis',
50
-
51
- # Single-hue sequential schemes
52
- 'YlOrRd': 'YlOrRd',
53
- 'Oranges': 'Oranges',
54
- 'Reds': 'Reds',
55
- 'Purples': 'Purples',
56
- 'Blues': 'Blues',
57
- 'Greens': 'Greens',
58
-
59
- # Diverging schemes
60
- 'coolwarm': 'RdBu_r',
61
- 'RdYlBu': 'RdYlBu',
62
- 'Spectral': 'Spectral',
63
- 'Spectral_r': 'Spectral_r',
64
- 'RdYlGn_r': 'RdYlGn_r',
65
-
66
- # Other schemes
67
- 'jet': 'Jet',
68
- 'turbo': 'Turbo'
69
- }
70
-
71
- print("🎨 Testing color theme mappings:")
72
- print(f"{'Color Theme':<15} {'Plotly Colorscale':<20} {'Status'}")
73
- print("-" * 50)
74
-
75
- for theme_key in COLOR_THEMES.keys():
76
- if theme_key in colormap_mapping:
77
- plotly_scale = colormap_mapping[theme_key]
78
- status = "✅ Mapped"
79
- else:
80
- plotly_scale = "Viridis (default)"
81
- status = "⚠️ Missing"
82
-
83
- print(f"{theme_key:<15} {plotly_scale:<20} {status}")
84
-
85
- missing_themes = set(COLOR_THEMES.keys()) - set(colormap_mapping.keys())
86
- if missing_themes:
87
- print(f"\n❌ Missing mappings for: {', '.join(missing_themes)}")
88
- return False
89
- else:
90
- print(f"\n✅ All {len(COLOR_THEMES)} color themes are properly mapped!")
91
- return True
92
-
93
-
94
- if __name__ == "__main__":
95
- print("🧪 Testing Interactive Plot Generator...")
96
- test_interactive_plot_generator()
97
- print("\n" + "="*60 + "\n")
98
- test_color_themes()
99
 
100
  def create_india_map(self, data_values, metadata, color_theme=None, save_plot=True, custom_title=None):
101
  """
 
33
  self.india_map = self.india_map.to_crs(epsg=4326)
34
 
35
  except Exception as e:
36
+ raise FileNotFoundError(f"Could not read the shapefile at '{shapefile_path}'. "
37
+ f"Please ensure the file exists. Error: {e}")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
 
39
  def create_india_map(self, data_values, metadata, color_theme=None, save_plot=True, custom_title=None):
40
  """