importmatplotlib.pyplotaspltimportnumpyasnp x=np.random.rand(100)y=np.random.rand(100)colors=x+y plt.figure(figsize=(8,6))scatter=plt.scatter(x,y,c=colors,cmap='viridis')plt.colorbar(scatter)plt.title('Color-co
y):returnnp.sin(x)*np.cos(y)# 生成网格数据x=np.linspace(-5,5,100)y=np.linspace(-5,5,100)X,Y=np.meshgrid(x,y)# 使用自定义函数计算Z值Z=custom_function(X,Y)# 创建3D图形fig=plt.figure(figsize=(12,9))ax=fig.add_subplot(111,projection='3d')# 绘制表面surf=ax.plot_...
matplotlib.colors.BoundaryNorm(boundaries, ncolors, clip=False, *, extend='neither') """ boundaries : array-like, Monotonically increasing sequence of at least 2 boundaries. ncolors : int, Number of colors in the colormap to be used. """ ...
Sometimes you want to highlight the actual data points on your line: import matplotlib.pyplot as plt import numpy as np # Create sample data - fewer points to make markers visible x = np.arange(0, 10, 0.5) y = np.sin(x) # Plot with markers plt.plot(x, y, 'bo-', markersize=8...
>>>plot(x1, y1,'g^', x2, y2,'g-') In this case, any additional keyword argument applies to all datasets. Also this syntax cannot be combinedwiththe *data* parameter. By default, each lineisassigned a different style specified by a ...
# As many colors as there are unique midwest['category'] categories = np.unique(midwest['category']) colors = [plt.cm.tab10(i / float(len(categories) - 1)) for i in range(len(categories))] # Step 2: Draw Scatterplot with unique color for each category fig = plt.figure(figsize=...
#plot some shapefile on the basemap as symbols #get the centriod points of thegeomerties data = pd.read_csv('stars.xy', sep=" ", header=None) data.columns = ["LONGITUDE", "LATITUDE"] #print(data) lats = data['LATITUDE'].values ...
colors = [plt.cm.tab10(i / float(len(categories) - 1)) for i in range(len(categories))] # Step 2: Draw Scatterplot with unique color for each category fig = plt.figure(figsize=(16, 10), dpi=80, facecolor='w', edgecolor='k') for i, category in enumerate(categories): plt.sca...
在 matplotlib 中,您可以使用 plt.scatterplot() 方便地执行此操作。 # Import dataset midwest = pd.read_csv("https://raw.githubusercontent.com/selva86/datasets/master/midwest_filter.csv") # Prepare Data # Create as many colors as there are unique midwest['category'] categories = np.unique(...
colors = [plt.cm.tab10(i/float(len(categories)-1))foriinrange(len(categories))] # Step 2: Draw Scatterplot with unique color for each category fig = plt.figure(figsize=(16,10), dpi=80, facecolor='w', edgecolor='k') fori, ...