0

In relation to the topic :Using matplotlib Polycollection to plot data from csv files . I wanted to make my plot but with log space data from the x axis!

I made this:

import matplotlib.pyplot as plt
from matplotlib.collections import PolyCollection
from mpl_toolkits.mplot3d import axes3d
import numpy as np

data1=eval(input())




freq_data =  np.logspace(-15,15,500)[:,None]*np.ones(10)[None,:]
amp_data = data1
rad_data = np.array([1,2,3,4,5,6,7,8,9,10])




verts = []
for irad in range(len(rad_data)):
      xs = np.concatenate([[freq_data[0,irad]], freq_data[:,irad], [freq_data[-1,irad]]])
      ys = np.concatenate([[0],amp_data[:,irad],[0]])
      verts.append(list(zip(xs, ys)))

poly = PolyCollection(verts)
poly.set_alpha(0.7)

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

# The zdir keyword makes it plot the "z" vertex dimension (radius)
# along the y axis. The zs keyword sets each polygon at the
# correct radius value.
ax.add_collection3d(poly, zs=rad_data, zdir='y')

ax.set_xlabel('symlog')
ax.set_xlim(freq_data.min(), freq_data.max())
ax.set_xlabel('Frequency')

ax.set_ylim(rad_data.min(), rad_data.max())
ax.set_ylabel('Radius')
ax.set_zlim(amp_data.min(), amp_data.max())
ax.set_zlabel('Amplitude')

plt.show()

but still i cannot get what i want. So i want to plot the data versus the frequency and the frequency is log spaced.

Attached is my input data: https://www.dropbox.com/s/63gs0n365mal3t6/test_data.mat?dl=0 you can downloaded and input it to the program.

Note: I have tried with random data instead of input and it did gave a proper plot. So please if you want to test the code do it with data attached.

Community
  • 1
  • 1
  • I don't think most people will be too keen to download some stranger's file from dropbox. Besides, that link will likely rot one day. It would be better to embed some of your data within your code using the `StringIO` module. – Paul H Nov 02 '16 at 13:09
  • I am sorry, iam new in using python and programming in general, how i can embed my data as every time i am running the code, the data should be as input even in the case of stringIO! – rami ahmed Nov 02 '16 at 14:34
  • just hard code some representative portion of your data into your example. the example should be the absolute *minimum* amount of code required to reproduce your problem. – Paul H Nov 02 '16 at 15:18

0 Answers0