Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Axes label rotation #2292

Closed
narasimhaprasad opened this issue Aug 11, 2013 · 8 comments
Closed

Axes label rotation #2292

narasimhaprasad opened this issue Aug 11, 2013 · 8 comments

Comments

@narasimhaprasad
Copy link

Axes labels are not parallel to the tick label, making the plot look as if it has been rotated.

Eg:
eff_map

@WeatherGod
Copy link
Member

When the text is short, we don't rotate the axes label in the same way as
for longer labels. To get around this, just put a few extra spaces before
and after the text. I don't have the docs in front of me to remember if
there is a keyword argument to override this naturally.

Ben Root

@narasimhaprasad
Copy link
Author

Weather God : Sorry, I added a ton of spaces. but could not get it to orient vertically. I am also unable to find the keyword argument to enable it. And I think you misunderstood my query. I am trying to point out the fact that axis and the axis label are not parallel.

@WeatherGod
Copy link
Member

Are you referring to the tick labels? Besides the z-axis label and the
title, the tick labels are the only things in that image that doesn't line
up with the axis.

If that is the case, there is no mechanism for turning that on right now.
It shouldn't be too hard to add, though.

@narasimhaprasad
Copy link
Author

For example 'Torque' is not parallel to the tick labels [(0, 0.5 1, 1.5, 2.0)]. Same issue with 'Speed'

@WeatherGod
Copy link
Member

Which version of matplotlib? This was fixed a few releases ago.

@narasimhaprasad
Copy link
Author

The latest 1.3.0.
Code

#Speed in RPM
spd_data = 1.5_np.array([1200, 1600, 2000, 3200, 4000, 4400, 4800,
5600, 6000])
#Speed in radians/s
spd_data_rad = spd_data_2*pi/60

#Torque
trq_data = 0.024_np.array([6.8, 13.6, 20.4, 27.2, 33.8, 40.6, 47.4, 54.2,
61, 67.8, 74.6, 81.4])
#Fuel Map
fuel_map = 1.4_np.array([[685.7, 635.7, 541.4, 447.2, 352.9, 332.2, 311.4, 322.4, 333.5, 333.5, 333.5, 333.5],
[678.4, 500.1, 443.8, 387.4, 331.1, 301.8, 297, 263.4, 269.8, 328, 335, 335],
[663.4, 483.4, 407.6, 350.1, 294.3, 280.8, 267.3, 253.9, 269.8, 303.2, 336.7, 336.7],
[699.1, 537.9, 480.3, 412.7, 301.4, 283.9, 266.3, 248.7, 258.8, 268.8, 271.9, 317.9],
[662.9, 592.9, 494.6, 393.4, 295.1, 279.4, 263.6, 247.9, 255.2, 262.5, 295, 320],
[667.9, 524.8, 381.6, 351.9, 322.2, 304.9, 287.5, 270.8, 290.8, 310.9, 320.9, 324],
[650.6, 530.6, 422.5, 411.1, 310, 305, 305.8, 304.2, 314.5, 324.8, 332.7, 337.7],
[698.4, 500.5, 428.6, 392.7, 356.8, 337.9, 328.4, 319, 328.8, 333.6, 338.7, 340.7],
[751.1, 637.8, 521.1, 407.8, 393.1, 378.4, 363.3, 348.2, 338.8, 340.2, 345.2, 350.2]])

#Efficiency Map
eff_map = (6.15_1000)/(fuel_map_33.44*2.2)

#Plot efficiency Surface Plot
spd_data_rad, trq_data = np.meshgrid(spd_data_rad, trq_data)
fig_map = figure(figsize = aspect_fig_wide)
ax_map = fig_map.add_subplot(111, projection='3d')
surf = ax_map.plot_surface(spd_data_rad, trq_data, eff_map.transpose()*100, rstride=1, cstride=1, linewidth=1, cmap=cm.Purples, alpha=0.9)

#formatting
ax_map.set_zlabel(r'$\eta$ (%)', fontsize=14)
ax_map.set_ylabel('Torque (N-m)')
ax_map.set_title('Efficiency Map of {}'.format(engine_name), loc='center', fontdict=dict(fontsize=16, horizontalalignment='center'), weight='semibold')
#ax_map.view_init(azim=-90-45)
ax_map.set_xlabel('Speed (rad/s)',rotation='horizontal')

#Savefig
savefig('../Images/eff_map.pdf')

@WeatherGod
Copy link
Member

Next time, please provide a completely self-contained example. The example provided did not have everything defined.

The image I get is the same as the one you posted, and I still don't understand. Take a look at the following simplified example (quickly pulled from an internal test script of mine):

import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')

ax.set_ylim(1, 0)
ax.set_xlabel('XXXXXXXXXXXXXXXXXXX')
ax.set_ylabel('YYYYYYYYYYYYYYYYYYY')
ax.set_zlabel('ZZZZZZZZZZZZZZZZZZZ')
plt.show()

mplot3d_axeslabels

The axes labels line up perfectly parallel to the axes line. So, perhaps I am still not understanding the issue you are seeing? Perhaps you want the tick label text to be parallel like the axes label text?

@tacaswell
Copy link
Member

closing for lack of activity.

@narasimhaprasad If this is still an issue please ping to have this re-opened.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants