emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: no inline images anymore after reinstall


From: Juan Manuel Macías
Subject: Re: no inline images anymore after reinstall
Date: Wed, 16 Jun 2021 12:51:41 +0000

Hi Johanna,

I don't have much knowledge of Python, but I have done this, in case it
helps you locate the problem:

- I have tried to evaluate your block (previously I have installed in my
  Arch system python-matplotlib). Output:
  
#+RESULTS: fig-zeitverlaufspgendrehstrom
[[file:]]

but

- I have noticed that if you comment on these two lines:

# plt.rcParams.update({'font.size':fontsize})
# rcParams.update({'figure.autolayout': True})

output:

#+RESULTS: fig-zeitverlaufspgendrehstrom
[[file:/tmp/babel-yXFqLG/figurepLRhLV.png]]

(Python console was returning these two errors before commenting
the lines:

NameError: name 'fontsize' is not defined
NameError: name 'rcParams' is not defined)

Best regards,

Juan Manuel 

Prof. Dr. Johanna May writes:

> Hi guys,
>
> I've been trying on the web and in "known as good" config files to solve
> this but cannot seem to find the solution:
>
> After reinstalling linux (openSuse leap 15.3) and finding out that
> unfortunately the distro is too new, so 27.1 does not yet get offered
> and switching back to 25.3 most of the stuff that I need works again.
>
> Except for including python output diagrams in org-babel. I put the
> diagram code at the very bottom since it takes up some space. At the very end
> you also see the output: it is not a file, it is just a link called
> [[file:]]. That cannot be right and then, of course, there are no inline
> images displayed and not exported either. It is remarkable though, that
> latex gets the link to the file, but just does not seem to show it
> right. This might point to a latex problem, but the inline images aren't
> shown in org-babel. Therefore I'm trying to find a solution here.
>
> In my dotemacs I included what I thought relevant to get it working, but
> it doesn't (below).
>
> I would be very glad about a hint where to look for a solution. Maybe
> some package-install (but which). Or some other configuration ... Or
> maybe I'm still lacking an important distro package that just does not
> get output on any error buffer?
>
> Thank you very much, any help is appreciated
>
> Johanna May
>
> --- some of my dotemacs lines ---
> ;; === org-babel - Code einbinden ===
> ;; ### Darstellung ###
> (setq org-startup-with-inline-images t)
> (setq org-confirm-babel-evaluate nil)
> (setq org-src-fontify-natively t)
> (setq org-src-tab-acts-natively t)
> (setq org-hide-emphasis-markers t)
>
> ;; ### Statistik mit R ESS ###
> (require 'ess-site)
>
> ;; ### org-babel Sprachen ###
> (require 'ob-python)
> (setq org-babel-python-command "python3")
> ;;(setq python-shell-interpreter "python3")
> (org-babel-do-load-languages
>  'org-babel-load-languages
>  '((emacs-lisp . t)
>    (python . t)
>    (ipython . t)
>    (shell . t)
>    (js . t)
>    (latex . t)
>    (org . t)
>    (octave . t)
>    (R . t)
>    (plantuml . t)
>    (dot . t)
>    (gnuplot . t)
>    (ruby . t)
>    (screen . nil)
>    (ledger . t)
>    (C . t)
>    (sql . t)
>    (ditaa . t)))
>
> ;; ### Einrückungen beachten (z. B. python) ###
> (setq org-edit-src-content-indentation 0)
> (setq org-src-tab-acts-natively t)
> (setq org-src-preserve-indentation t)
>
> ;; ### python-Coding ###
> (require 'epc)
> (require 'company)
> (add-hook 'after-init-hook 'global-company-mode)
> (global-font-lock-mode t)
> (setq font-lock-maximum-decoration t)
> (setq-default indent-tabs-mode nil) ;; nicht Tabs sondern 4 Leerzeichen
> (setq default-tab-width 4)
> (add-hook 'python-mode-hook 'anaconda-mode)
> (add-hook 'python-mode-hook 'eldoc-mode)
> (eval-after-load "company"
>   '(progn
>      (add-to-list 'company-backends 'company-anaconda)))
> (add-hook 'python-mode-hook 'anaconda-mode)
>
> ;; ### Bilder aus python inline anzeigen ###
> (add-hook 'org-babel-after-execute-hook 'org-display-inline-images 'append)
> (add-hook 'org-mode-hook 'org-display-inline-images)
> --- snip ---
>
>
> ---diagram code in org---
>
>     #+name: fig-zeitverlaufspgendrehstrom
> #+begin_src python :results file :session :var 
> matplot_lib_filename=(org-babel-temp-file "figure" ".png"),fontsize=fs 
> :exports results
>
> import matplotlib.pyplot as plt
> plt.style.use('classic')
> import numpy as np
> from matplotlib.ticker import FuncFormatter, MultipleLocator
> plt.style.use('classic')
>
> plt.rcParams.update({'font.size':fontsize})
> rcParams.update({'figure.autolayout': True})
>
> fig=plt.figure(figsize=(6,3))
>
> x=np.linspace(0,5*np.pi,1000)
> udach=230*np.sqrt(2)
> phi1=0
> phi2=-np.pi*2/3
> phi3=-np.pi*4/3
> u1=udach*np.cos(x+phi1)
> u2=udach*np.cos(x+phi2)
> u3=udach*np.cos(x+phi3)
>
> plt.plot(x,u1,label='$u_1(t)$')
> plt.plot(x,u2,label='$u_2(t)$')
> plt.plot(x,u3,label='$u_3(t)$')
> plt.xlabel('$t$')
> plt.ylabel('$u$')
> plt.xticks([])
> plt.yticks([])
> plt.legend(fontsize='small',bbox_to_anchor=(0,1.02,1.02,0),loc=3,ncol=3,mode="expand",borderaxespad=0.)
> plt.grid(True)
> plt.axhline(0,color='black',lw=1)
>
> #plt.tight_layout()
> plt.savefig(matplot_lib_filename,bbox_inches='tight')
> matplot_lib_filename
> #+end_src
>
> #+CAPTION: Zeitverlauf symmetrischer Spannungen
> #+LABEL: fig-zeitverlaufspgendrehstrom
>
> #+ATTR_LATEX: :width \textwidth :height \textheight :options 
> angle=0,keepaspectratio :float nil
>
> #+RESULTS: fig-zeitverlaufspgendrehstrom
> [[file:]]
>
> ---snip ---
>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]