Curve Fitting to a time series in the format ‘datetime’?

Instead of plotting datenums, use the associated datetimes. import numpy as np import matplotlib.pyplot as plt import matplotlib.dates as mdates import datetime as DT import time dates = [DT.datetime(1978, 7, 7), DT.datetime(1980, 9, 26), DT.datetime(1983, 8, 1), DT.datetime(1985, 8, 8)] y = [0.00134328779552718, 0.00155187668863844, 0.0039431374327427, 0.00780037563783297] yerr = [0.0000137547160254577, 0.0000225670232594083, 0.000105623642510075, 0.00011343121508] x = mdates.date2num(dates) … Read more

Show decimal places and scientific notation on the axis

This is really easy to do if you use the matplotlib.ticker.FormatStrFormatter as opposed to the LogFormatter. The following code will label everything with the format ‘%.2e’: import numpy as np import matplotlib.pyplot as plt import matplotlib.ticker as mtick fig = plt.figure() ax = fig.add_subplot(111) x = np.linspace(0, 300, 20) y = np.linspace(0,300, 20) y = … Read more

pROC ROC curves remove empty space

Make sure the plotting device is square and adjust the margins so that top + bottom == left + right: library(pROC) png(“test.png”, width = 480, height = 480) par(mar = c(4, 4, 4, 4)+.1) n = c(4, 3, 5) b = c(TRUE, FALSE, TRUE) rocobj <- plot.roc(b, n, percent = TRUE, main=”ROC”, col=”#1c61b6″, add=FALSE) dev.off()