I am plotting some results on a bar graph. I apply the fantasy font style but I do not believe the fantasy font style is what's being displayed. I have also tried to remove the bold text from the tick labels with no success. My code is as follows:
import numpy as np
import pandas as pd
from sklearn import svm
from sklearn import metrics
from sklearn.model_selection import train_test_split
import matplotlib.pyplot as plt
file_name = 'path here'
input_data = pd.read_csv(file_name + '.csv', header=0)
X = np.column_stack((input_data["X1"].values, input_data["X2"].values))
Y = input_data["Y"].values
X_train, X_test, Y_train, Y_test = train_test_split(X, Y, test_size = 0.3)
ker = ['linear', 'poly', 'rbf', 'sigmoid', 'precomputed']
ker_range = list(range(0,4,1))
values = []
for k in ker_range:
vector = svm.SVC(kernel=ker[k], degree=3)
vector.fit(X_train, Y_train)
Y_predict = vector.predict(X_test)
yp = (Y_predict)
yt = (Y_test)
values.append(metrics.accuracy_score(Y_predict, Y_test))
accuracy = (values)
fig = plt.figure()
ax = fig.add_axes([1,1,1,1])
kernels = ['Linear', 'Poly', 'RBF', 'Sigmoid']
bcolor = ['#669AC0']
plt.rcParams.update({'font.family':'fantasy'})
ax.bar(kernels, accuracy, width = 0.4, color = bcolor)
plt.xlabel("Accuracy Scores", fontsize = 14)
plt.ylabel("Kernel Function", fontsize = 14)
plt.xticks(fontsize=12, weight = 'normal')
plt.yticks(fontsize=12, weight = 'normal')
plt.show()
This is the resulting graph. Clarification on the font style actually being fantasy and how to adjust the ticks to not be bold.
I made changes. I believe my issue is specifically with the fantasy font. I changed the font to comic sans and made some adjustments to the plotting code as follows:
fig = plt.figure()
ax = fig.add_axes([1,1,1,1])
kernels = ['Linear', 'Poly', 'RBF', 'Sigmoid']
bcolor = ['#669AC0']
csfont = {'fontname':'Comic Sans MS'}
ax.bar(kernels, accuracy, width = 0.4, color = bcolor)
plt.xlabel("Kernel Function", fontsize = 14, **csfont, weight =
'bold')
plt.ylabel("Accuracy Score", fontsize = 14, **csfont, weight =
'bold')
plt.xticks(fontsize=12, weight = 'normal', **csfont)
plt.yticks(fontsize=12, weight = 'normal', **csfont)
plt.show()
I then get these results. Is there an issue with fantasy font? I change the comic sans to fantasy and I get the default looking text I got in the first graph.