I made a program for drawing graphs function but I don't know how to replace the image when drawing again
(defun eilmc-infix-plot () "" (interactive) (switch-to-buffer "*Function Plotter*") (kill-all-local-variables) (make-local-variable 'expr-widget) (make-local-variable 'error-widget) (let ((inhibit-read-only t)) (erase-buffer)) (remove-overlays) (setq expr-widget (widget-create 'editable-field :format "Function (infix notation):\n%v" "x^2")) (widget-insert "\n") (widget-insert "Error: ") (setq error-widget (widget-create 'item :value "")) (widget-insert "\n") (widget-create 'push-button :notify (lambda (&rest ignore) (condition-case err (let* ((expr (widget-value expr-widget)) (tokens (elimc-tokenize-math-expression expr)) (rpn (elimc-shunting-yard tokens)) (image (elimc-fill-image (elimc-create-image 400 400) 0))) ;; grid (dotimes (x 400) (dotimes (y 400) (when (or (= (mod x 50) 0) (= (mod y 50) 0)) (elimc-setpixel image x y 1)))) ;; plot (dotimes (x 400) (let* ((x-val (- (/ (* x 8.0) 400) 4)) ;; X (y-val (elimc-rpn-calc rpn x-val)) (y (round (- 200 (* 50 y-val))))) ;; Y (when (and (>= y 0) (< y 400)) (elimc-setpixel image x y 1)))) ;; display img (let ((pbm (elimc-image-to-pbm image))) (with-current-buffer "*Function Plotter*" (let ((inhibit-read-only t)) (goto-char (point-max)) (widget-image-insert result-widget "The console does not support images" (create-image pbm 'pbm "")))))) (error (widget-value-set error-widget (error-message-string err))))) "Plot") (widget-insert "\n") (setq result-widget (widget-create 'item :value "")) (use-local-map widget-keymap) (widget-setup))
elimc-*functions that you use or an indication where the library can be found. Please provide that information.