1+ import matplotlib .pyplot as plt
2+ import numpy as np
3+
4+ # Set the style
5+ plt .style .use ('default' )
6+ fig , ax = plt .subplots (figsize = (12 , 7 ))
7+ fig .set_facecolor ('#f8f9fa' )
8+ ax .set_facecolor ('#ffffff' )
9+
10+ # Generate data
11+ x = np .linspace (0 , 10 , 100 )
12+ y1 = np .sin (x )
13+ y2 = np .cos (x )
14+
15+ # Create plots with modern styling
16+ ax .plot (x , y1 , label = "Sine" , color = '#4361ee' , linewidth = 2.5 )
17+ ax .plot (x , y2 , label = "Cosine" , color = '#f72585' , linewidth = 2.5 )
18+
19+ # Customize the plot with modern aesthetics
20+ ax .set_title ('Sine and Cosine Functions' , fontsize = 16 , pad = 20 , fontweight = 'bold' )
21+ ax .set_xlabel ('x' , fontsize = 12 , labelpad = 10 )
22+ ax .set_ylabel ('y' , fontsize = 12 , labelpad = 10 )
23+
24+ # Improve grid and spines
25+ ax .grid (True , linestyle = '--' , alpha = 0.3 , color = '#666666' )
26+ ax .spines ['top' ].set_visible (False )
27+ ax .spines ['right' ].set_visible (False )
28+
29+ # Enhanced legend
30+ ax .legend (fontsize = 11 , framealpha = 0.95 , loc = 'upper right' )
31+
32+ # Add a slight margin to the plot
33+ ax .margins (x = 0.02 )
34+
35+ # Adjust layout and display
36+ plt .tight_layout ()
37+ plt .show ()
38+ plt .show ()
0 commit comments