简体   繁体   English

如何在python中使用matplotlib在同一图形上绘制另一组轴?

[英]How to draw another set of axis on the same figure using matplotlib in python?

I want my mathplotlib figure to have another set of axis/lines. 我希望我的mathplotlib图具有另一组轴/线。 Currently I do as follows: 目前,我的工作如下:

plt.plot([0,eigenVectors[0][0]],[0,eigenVectors[1][0]],color='k',marker='o')
plt.plot([0,eigenVectors[0][1]],[0,eigenVectors[1][1]],color='k',marker='o')

where eigenVector is a 2d matrix and I am just trying to draw lines passing through the eigenvectors and the origin. 其中eigenVector是2D矩阵,我只是试图绘制穿过特征向量和原点的线。 However, as it is evident, I am drawing two line segments not lines. 但是,很明显,我正在绘制两个线段而不是线。 I wish to draw two lines passing through origin and the eigenvectors. 我希望画两条穿过原点和特征向量的线。 Is there a way to say that draw a line (not a line segment) passing through two points? 有没有办法说画一条穿过两个点的线(不是线段)?

My current plot looks like this: 我当前的情节看起来像这样:

在此处输入图片说明

PS: I am trying to implement PCA. PS:我正在尝试实施PCA。

You could extrapolate linearly to some large values and use them to plot the lines. 您可以线性外推到一些大值,然后使用它们来绘制线条。 Then limit the plt.xlim and plt.ylim to some sensible value. 然后将plt.xlimplt.ylim限制为一个合理的值。 For more information on the extrapolation, see this post . 有关外推的更多信息,请参见这篇文章

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用Matplotlib在图的中间绘制轴 - How to draw an axis in the middle of the figure using Matplotlib 如何在matplotlib python 2.6.6中在我的图形中的X轴上设置“步骤”? - How to set “step” on axis X in my figure in matplotlib python 2.6.6? 如何在matplotlib中绘制一条轴外的线(图中坐标)? - How to draw a line outside of an axis in matplotlib (in figure coordinates)? 通过python matplotlib在同一图中有一个轴的多个图 - multiple plots in same figure with one axis via python matplotlib 如何在我的图中 matplotlib python 2.7 或 3.5 中的 X 轴上设置不同的“步长”? - How to set different “step” on axis X in my figure in matplotlib python 2.7 or 3.5? 如何使用 matplotlib 使每个轴上具有不同范围的子图具有相同的图形大小? - How to make subplots having different range on each axis have the same figure size using matplotlib? 如何在使用matplotlib的pyplot绘制的图形上设置x轴标签? - How to set x-axis labels on a figure plotted using matplotlib's pyplot? 如何使用 Matplotlib 在 Python 中的同一 Y 轴上有 2 个不同的刻度 - How to have 2 different scales on same Y axis in Python using Matplotlib 如何在 Python matplotlib 中设置图形的大小 - How to set the size of a figure in Python matplotlib 如何在matplotlib中设置“纯”数字(没有轴刻度或标题)的大小 - How to set the size of the “pure” figure (without axis ticks or title) in matplotlib
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM