Welcome to the forums. Please post in English or French.

You are not logged in.

#1 2019-03-27 08:51:55

nirmaljoshi
Member
From: Japan
Registered: 2018-10-12
Posts: 152

[solved] printing multiple lines in XMGRACE

I want to print results of fore-dispacement curve for multiple cases in a single graph using XMGRACE using python. My concept is as follows. But so far, only one curve gets displayed. How should I modify it?

#variable for various degree 
vCHCOR = range(0,95,20)
itr=len(vCHCOR)
.......
..
for i in range(itr)
......
...
    force[i] = RECU_FONCTION(GROUP_NO=('Group_loadingnode', ),
                        NOM_CHAM='REAC_NODA',
                        NOM_CMP='DX',
                        RESULTAT=rxn[i])
    
    depl[i] = RECU_FONCTION(GROUP_NO=('Group_loadingnode', ),
                        NOM_CHAM='DEPL',
                        NOM_CMP='DX',
                        RESULTAT=nl[i])
....
...
#make result file

for i in range(itr):
            IMPR_FONCTION(COURBE=(_F(FONC_X=depl[i],FONC_Y=force[i])),
                FORMAT='XMGRACE',
                PILOTE='EPS',
                LEGENDE_X='Displacement',
                LEGENDE_Y='Force',
                UNITE=15)

Last edited by nirmaljoshi (2019-04-01 08:22:04)

Offline

#2 2019-03-27 10:02:40

mecour
Member
From: Ostrava (Czech)
Registered: 2011-04-04
Posts: 143

Re: [solved] printing multiple lines in XMGRACE

Hello,

In that way you use for image write you just overwrite the same image. So you just obtain the last curve of result. You need to duplicate the concept COURBE  in IMPR_FONCTION an not repeat the whole IMPR_FONCTION with the for cycle.
The way how to plot multiple curves you can find in the book Beginnig with Code_Aster. For example the chapter 13.1.3.

Offline

#3 2019-03-27 15:52:36

jeanpierreaubry
Guru
From: nantes (france)
Registered: 2009-03-12
Posts: 3,622

Re: [solved] printing multiple lines in XMGRACE

hello

@mecour
YES and NO,

as long as yo do not change UNITE the COURBE are added to the file
see below

&nirmaljoshi
your method seems valid as long as you drop the line
PILOTE='EPS',
there should be an ALARM about this in the .mess file

   !------------------------------------------------------------------------!
   ! <A> <GRAPH0_11>                                                        !
   !                                                                        !
   !    Le fichier 'fort.31' ne semble pas être au format texte de xmgrace. !
   !    On ne peut donc pas recalculer les valeurs extrêmes.                !
   !    Le pilote ne permet probablement pas d'imprimer plusieurs           !
   !    graphiques dans le même fichier.                                    !
   !                                                                        !
   ! Conseil :                                                              !
   !    N'utilisez pas le mot-clé PILOTE et produisez l'image en            !
   !    utilisant xmgrace.                                                  !
   !                                                                        !
   !                                                                        !
   ! Ceci est une alarme. Si vous ne comprenez pas le sens de cette         !
   ! alarme, vous pouvez obtenir des résultats inattendus !                 !
   !------------------------------------------------------------------------!

jean pierre aubry


consider reading my book
freely available here https://framabook.org/beginning-with-code_aster/

Offline

#4 2019-03-31 05:50:50

nirmaljoshi
Member
From: Japan
Registered: 2018-10-12
Posts: 152

Re: [solved] printing multiple lines in XMGRACE

@jeanpierreaubry
No, i did not get any error even I use PILOT but I only got single line in the image file.

If i drop PILOTE='EPS', the output file will be a plain text file, yes it contains all the plot data; but I need to process it using command line xmgrace separately (grace -nxy graph1.txt -hdevice PNG -hardcopy -printfile output.png)

Isn't it possible to do it within the code-aster command? For example, when I hard write the code (without python) as follows the graph is plotted well.

IMPR_FONCTION(FORMAT='XMGRACE',
              PILOTE='EPS',UNITE=24,
              COURBE=(_F(FONCTION=NdeU,
                         LEGENDE='O% CORROSION',),
                      _F(FONCTION=NdeU2,
                         LEGENDE='2.5% CORROSION',),
                      _F(FONCTION=NdeU3,
                         LEGENDE='13% CORROSION',),),);

Last edited by nirmaljoshi (2019-03-31 08:02:10)


Attachments:
graph.zip, Size: 3.36 KiB, Downloads: 76

Offline

#5 2019-03-31 10:41:31

jeanpierreaubry
Guru
From: nantes (france)
Registered: 2009-03-12
Posts: 3,622

Re: [solved] printing multiple lines in XMGRACE

why trying to make things complicated when they are simple
xmgrace $filename does the job
the do the rest within xmgrace

this said your files runs ok on my komputer, attached is the result


Attachments:
grace.png, Size: 13.05 KiB, Downloads: 70

consider reading my book
freely available here https://framabook.org/beginning-with-code_aster/

Offline

#6 2019-04-01 04:06:17

nirmaljoshi
Member
From: Japan
Registered: 2018-10-12
Posts: 152

Re: [solved] printing multiple lines in XMGRACE

Thanks for you time @jeanpierreaubry

Actually, I wanted to avoid the step to type the command in terminal. Seems that is unavoidable?

Offline

#7 2019-04-01 07:06:17

jeanpierreaubry
Guru
From: nantes (france)
Registered: 2009-03-12
Posts: 3,622

Re: [solved] printing multiple lines in XMGRACE

if you save the file the file with the extension .agr your file browser may launch it with a double click
you may also launch it from astk
or use some other hints decribed in my book


consider reading my book
freely available here https://framabook.org/beginning-with-code_aster/

Offline