How to make labels for these quiver vector frames in python ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 8

How to make labels for these quiver vector frames in python ?

By labels I mean {X_1} frame , {Y_1} so on... https://code.sololearn.com/c5K6e9h6X2BV/#py

18th Feb 2019, 6:58 AM
Zhenis Otarbay
Zhenis Otarbay - avatar
2 Answers
+ 1
OK now I got the labels working for each quiver arrow: # label using same coords as quiver end point ax.quiver(0, 0, 0, scale1, 0, 0, color='red') ax.text(scale1, 0, 0, 'arrow1', fontsize=8, color='green') ax.quiver(0, 0, 0, 0, scale1, 0, color='red') ax.text(0, scale1, 0, 'arrow2', fontsize=8, color='blue') ax.quiver(0, 0, 0, 0, 0, scale1, color='red') ax.text(0, 0, scale1, 'arrow3', fontsize=8, color='purple') parameters of the text() are - 3 coordinates, I used the endpoints of the arrow - and the text - fontsize and color are optional, you may want to use same color as the arrow. Enjoy ;)
21st Feb 2019, 8:16 AM
Tibor Santa
Tibor Santa - avatar
+ 2
Hey Zhenis, I am not sure if this is what you had in mind, but based on the documentation of Axes3D, I was able to add a label to each ax like this: ax.set_xlabel('X') ax.set_ylabel('Y') ax.set_zlabel('Z') https://matplotlib.org/api/_as_gen/mpl_toolkits.mplot3d.axes3d.Axes3D.html I made a lot of simplification on your code. Library imports were redundant and sometimes inconsistent, you see it works with only these imports: import matplotlib.pyplot as plt from math import pi, sin, cos from numpy import matrix, double from mpl_toolkits.mplot3d import Axes3D ; semicolon not needed at the end of lines all symbols definitions seemed redundant (because they were later overridden by normal python variable declarations so this is how it looks now, 135 lines instead of 222: https://code.sololearn.com/cTLjDNcorlt8/#py EDIT: code updated.
20th Feb 2019, 6:36 PM
Tibor Santa
Tibor Santa - avatar