Gist of my question:
I have data that I am plot_surface
-ing with python. How should I change the values of my xticks
and yticks
and perhaps their frequency?
Details of my question
I have data such as this. I had to upload my data file to dropbox as it is too large to reproduce here and I am not sure that a "minimal example" would do justice.
I have several such data files in a folder (think several dozens really) on which I run a python script that loads each such data file and creates a surface plot. My python code looks like this:
python code
import os
import glob
import sys
import subprocess
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
from numpy import *
from numpy.random import rand
from pylab import pcolor, show, colorbar, xticks, yticks
from pylab import *
for fname in glob.glob('*profile*.dat'):
with open(fname) as f:
data = np.loadtxt(fname)
z = np.array(data)
x,y = np.meshgrid(range(data.shape[0]), range(data.shape[1]))
fig = plt.figure()
ax = fig.gca(projection='3d')
ax.plot_surface(x, y, z, rstride=5, cstride=5,cmap="binary",linewidth=0.1)
ax.set_zlim3d(0.0,4.0)
ax.set_xlabel('X',fontsize=16,fontweight="bold")
ax.set_ylabel('Y',fontsize=16,fontweight="bold")
ax.set_zlabel('h(X,T)',fontsize=16,fontweight="bold")
savefig('/home/uid/Desktop/'+fname.replace(".dat","")+'.eps',figsize=(5,5),dpi=600)
savefig('/home/uid/Desktop/'+fname.replace(".dat","")+'.pdf',figsize=(5,5),dpi=600)
print "Profile plots have been saved!"
"EOF"
The plot looks like so:
Observations/What I am trying to accomplish:
What I need to do is change the xticks and yticks to other numbers. What is shown in the plot are actually "grid points" used. My X and Y lengths are actually "50 units" each with about 265 grid points used in each direction.
How do I change the xticks and yticks to show "0... 50" on the x and y axis?
I apologize if this question seems sophomoric but I have been searching for ways to go about it but have come up with only a minimal set of answers. 1 2.