我写了一个简单的代码来构造一个图,它工作得很好。但是,我不知道如何修改它像下面这样?如何在matplotlib中自定义行?
要求:
我的密码
import matplotlib.pyplot as plt
# Data for different models and their corresponding accuracies
models = ['10', '60', '110', '160']
accuracies = [73.2, 75.6, 77.1, 78.3]
transmix_accuracies = [74.8, 76.4, 78.2, 79.1]
# Create a figure and axis object
fig, ax = plt.subplots()
# Plot the accuracy of ViT-based models
ax.plot(models, accuracies, marker='o', label='ViT')
# Plot the accuracy of TransMix models
ax.plot(models, transmix_accuracies, marker='o', label='TransMix')
# Set the chart title and axis labels
#ax.set_title("Improvement of TransMix on ViT-based Models")
ax.set_xlabel("Number of Parameters")
ax.set_ylabel("ImageNet Top-1 Acc (%)")
# Add a legend
ax.legend()
# Show the plot
plt.show()
输出
1条答案
按热度按时间3bygqnnd1#
您可以添加一些说明,如:
现在,您可以使用
annotate
或text
自定义图形输出