Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Phillipp33 opened this issue Aug 10, 2023 · 0 comments
Open

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

Phillipp33 opened this issue Aug 10, 2023 · 0 comments

Comments

@Phillipp33
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant