I would like to plot in a single line ticks according to an array (up to 1000 elements). I would rather not to use something like:
plt.xticks(energies[i][j])
because each sample value is written up below tick. I have looked extensively at Matplotlib documentation but didn't find nothing besides hist(). If you guys know other way to visualize 1D arrays into a single line I would very much appreciate, especially if it involves colors representing density of values.
I'm using Spyder 2.2.5, Python 2.7.6 | 64-bit in OSX 10.7.4
1D Plots - (one-dimensional) plots allow you to display one parameter of your data. You can also display a cumulative probability distribution of your data.
The quickest way to generate a simple, 1-D plot is using the pyplot. plot() function. the figure and axis objects and plots the data onto them. the figure and axes objects automatically, and is the simplest way to create a plot.
To plot a line plot in Matplotlib, you use the generic plot() function from the PyPlot instance.
Edit As @tcaswell mentions in comments, eventplot is a good way to do this. Here is an example:
from matplotlib import pyplot as plt
import numpy as np
plt.figure()
a = [1,2,5,6,9,11,15,17,18]
plt.hlines(1,1,20) # Draw a horizontal line
plt.eventplot(a, orientation='horizontal', colors='b')
plt.axis('off')
plt.show()
Or you can use vertical line markers? The example below has the basic idea. You could change the color of the markers to represent density.
from matplotlib import pyplot as plt
import numpy as np
a = [1,2,5,6,9,11,15,17,18]
plt.hlines(1,1,20) # Draw a horizontal line
plt.xlim(0,21)
plt.ylim(0.5,1.5)
y = np.ones(np.shape(a)) # Make all y values the same
plt.plot(a,y,'|',ms = 40) # Plot a line at each location specified in a
plt.axis('off')
plt.show()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With