Creating graph with date and time in ticklabels with matplotlib

I hope this helps. I’ve always had a hard time with matplotlib’s dates. Matplotlib requires a float format which is days since epoch. The helper functions num2date and date2num along with python builtin datetime can be used to convert to/from. The formatting business was lifted from this example. You can change an axis on any … Read more

Plot Pandas DataFrame as Bar and Line on the same one chart

The DataFrame plotting methods return a matplotlib AxesSubplot or list of AxesSubplots. (See the docs for plot, or boxplot, for instance.) You can then pass that same Axes to the next plotting method (using ax=ax) to draw on the same axes: ax = df_13_14_target[[‘month’,’2014_target_val’]].plot(x=’month’,linestyle=”-“, marker=”o”) df_13_14_target[[‘month’,’2013_val’,’2014_val’]].plot(x=’month’, kind=’bar’, ax=ax) import pandas as pd import matplotlib.pyplot as … Read more

Scatter plot with color label and legend specified by c option [duplicate]

As in the example you mentioned, call plt.scatter for each group: import numpy as np from matplotlib import pyplot as plt scatter_x = np.array([1,2,3,4,5]) scatter_y = np.array([5,4,3,2,1]) group = np.array([1,3,2,1,3]) cdict = {1: ‘red’, 2: ‘blue’, 3: ‘green’} fig, ax = plt.subplots() for g in np.unique(group): ix = np.where(group == g) ax.scatter(scatter_x[ix], scatter_y[ix], c = … Read more

When plotting with Bokeh, how do you automatically cycle through a color pallette?

It is probably easiest to just get the list of colors and cycle it yourself using itertools: import numpy as np from bokeh.plotting import figure, output_file, show # select a palette from bokeh.palettes import Dark2_5 as palette # itertools handles the cycling import itertools output_file(‘bokeh_cycle_colors.html’) p = figure(width=400, height=400) x = np.linspace(0, 10) # create … Read more

Line plot with arrows

You can do this with quiver, but it’s a little tricky to get the keyword arguments right. import numpy as np import matplotlib.pyplot as plt x = np.linspace(0, 2*np.pi, 10) y = np.sin(x) plt.figure() plt.quiver(x[:-1], y[:-1], x[1:]-x[:-1], y[1:]-y[:-1], scale_units=”xy”, angles=”xy”, scale=1) plt.show()

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)