Skip to content

Plotstyle Classic creates fill opacity = None, Error in Latex #592

@Phillipp33

Description

@Phillipp33

Error appears when using plotstyle Classic. Could be with others as well, but I didn't check all possible entries.

import torch
import torch.nn.functional as F
import numpy as np
import matplotlib.pyplot as plt
import tikzplotlib

# Used for tikzplotlib
plt.style.use("classic")

# Create x values
x = torch.linspace(-3.5, 3.5, 100)
x_np = x.numpy()

# Compute activations and derivatives
sigmoid = torch.sigmoid(x).numpy()
sigmoid_prime = sigmoid * (1 - sigmoid)

tanh = torch.tanh(x).numpy()
tanh_prime = 1 - torch.tanh(x)**2

# Create subplots
fig, axs = plt.subplots(1, 2, figsize=(10, 4))

# Plot Sigmoid
axs[0].plot(x_np, sigmoid, label='f')
axs[0].plot(x_np, sigmoid_prime, label="f'")
axs[0].set_title('Sigmoid')
axs[0].legend(loc='upper left')

# Plot Tanh
axs[1].plot(x_np, tanh, label='f')
axs[1].plot(x_np, tanh_prime, label="f'")
axs[1].set_title('Tanh')
axs[1].legend(loc='upper left')

# Adjust layout
plt.tight_layout()
tikzplotlib.save("Classic_activations.tex")

# Show plot
plt.show()

This outputs a .tex file with fill opacity = None, which is not allowed in Latex.
Manually changing this entry to something between 0 and 1 removes the error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions