'Programming/python(파이썬)'에 해당되는 글 95건

  1. 2024.01.17 파이썬 소켓 예제
  2. 2024.01.11 ipython notebook -> jupyter notebook
  3. 2024.01.09 파이썬 가상환경
  4. 2023.10.05 pyplot legend picking
  5. 2023.10.04 matplotlib
  6. 2023.10.04 pyplot
  7. 2023.03.08 python matplotlib 설치
  8. 2022.04.12 python openCV / PIL 포맷 변경
  9. 2022.04.12 파이썬 딕셔너리 변수 생성과 리턴 enumerate, zip
  10. 2022.03.15 python interactive mode

 

블러킹 방식이지만 잘 되긴 함.

[링크 : https://1d1cblog.tistory.com/69

 

그래서 멀티쓰레드로 작동하게 해야하나? 고민중

[링크 : https://m.blog.naver.com/jkg57/222480924841]

[링크 : https://nachwon.github.io/asyncio-futures/]

 

[링크 : https://orashelter.tistory.com/47]

[링크 : https://docs.python.org/3.6/library/asyncio-protocol.html]

'Programming > python(파이썬)' 카테고리의 다른 글

matplotlib grayscale image to 3d graph  (0) 2024.02.22
python tcp 서버 예제  (0) 2024.01.22
ipython notebook -> jupyter notebook  (0) 2024.01.11
파이썬 가상환경  (0) 2024.01.09
pyplot legend picking  (0) 2023.10.05
Posted by 구차니

interactive python 해서 ipython인가?

notebook은 ipython 꺼였는데 jupyter의 일부가 되었다고 한다.

Installing IPython

There are multiple ways of installing IPython. This page contains simplified installation instructions that should work for most users. Our official documentation contains more detailed instructions for manual installation targeted at advanced users and developers.
If you are looking for installation documentation for the notebook and/or qtconsole, those are now part of Jupyter.

[링크 : https://ipython.org/install.html]

[링크 : https://pypi.org/project/ipython/]

[링크 : https://yujuwon.tistory.com/m/entry/ipython-노트북-설치하기]

'Programming > python(파이썬)' 카테고리의 다른 글

python tcp 서버 예제  (0) 2024.01.22
파이썬 소켓 예제  (0) 2024.01.17
파이썬 가상환경  (0) 2024.01.09
pyplot legend picking  (0) 2023.10.05
matplotlib  (0) 2023.10.04
Posted by 구차니

이것저것 조사해보는데

무식하지만 가장 확실한(?) docker로 버전별로 혹은 프로젝트 별로 생성하는 것부터

python 에서 제공하는 venv

venv를 확장해서 사용하는 virtualenv

그리고 conda 정도로 정리되는 듯.

 

 

conda

[링크 : https://m.blog.naver.com/jonghong0316/221683053696]

 

virtualenv, venv

[링크 : https://jaemunbro.medium.com/python-virtualenv-venv-설정-aaf0e7c2d24e]

 

conda, venv

[링크 : https://yongeekd01.tistory.com/39]

 

venv, pipenv, conda, docker(이걸.. 가상이라고 하긴 해야 하는데.. 해줘야 하는거 맞....나?)

[링크 : https://dining-developer.tistory.com/21]

 

virtualenv, pyenv, pipenv

[링크 : https://jinwoo1990.github.io/dev-wiki/python-concept-3/]

 

+

conda - Conda provides package, dependency, and environment management for any language.

파이썬 전용이 아닌가?

[링크 : https://docs.conda.io/en/latest/]

[링크 : https://anaconda.org/]

[링크 : https://anaconda.org/anaconda/conda]

 

+

virtualenv

is slower (by not having the app-data seed method),
is not as extendable,
cannot create virtual environments for arbitrarily installed python versions (and automatically discover these),
is not upgrade-able via pip,
does not have as rich programmatic API (describe virtual environments without creating them).

[링크 : https://virtualenv.pypa.io/en/latest/]

 

+

venv

[링크 : https://docs.python.org/3/library/venv.html] 3.12.1

 

venv는 3.7 이후부터 사용이 가능한 것으로 보임. 즉, 버전별로 호환성은 없을 가능성이 있음

pyvenv 스크립트는 파이썬 3.6 에서 폐지되었고, 가상 환경이 어떤 파이썬 인터프리터를 기반으로 하는지에 대한 잠재적인 혼동을 방지하기 위해 python3 -m venv를 사용합니다.

[링크 : https://docs.python.org/ko/3.7/library/venv.html]

'Programming > python(파이썬)' 카테고리의 다른 글

파이썬 소켓 예제  (0) 2024.01.17
ipython notebook -> jupyter notebook  (0) 2024.01.11
pyplot legend picking  (0) 2023.10.05
matplotlib  (0) 2023.10.04
pyplot  (0) 2023.10.04
Posted by 구차니

이 선이 머다~ 라고 써있는데 legend인데

거기 클릭하면 선이 보이고 안보이고 하는 기능을 picking이라고 적어 놓은듯

 

우측 상단에 1 Hz / 2 Hz가 legend인데

레전드 내의 파란색 선을 아~~~주 잘 골라서 클릭하면

 

아래처럼 사라진다.

[링크 : https://matplotlib.org/stable/gallery/event_handling/legend_picking.html]

'Programming > python(파이썬)' 카테고리의 다른 글

ipython notebook -> jupyter notebook  (0) 2024.01.11
파이썬 가상환경  (0) 2024.01.09
matplotlib  (0) 2023.10.04
pyplot  (0) 2023.10.04
python matplotlib 설치  (0) 2023.03.08
Posted by 구차니

gnuplot을 래핑해서 만든건줄 알았는데 독립된 건가?

[링크 : https://matplotlib.org/stable/tutorials/pyplot.html]

 

500.000 points scatterplot
gnuplot:      5.171 s
matplotlib: 230.693 s

[링크 : https://stackoverflow.com/questions/911655/gnuplot-vs-matplotlib]

 

2차축 추가. y축에 대해서 주로 넣지 x 축에 넣는건 먼가 신선하네

import datetime

import matplotlib.pyplot as plt
import numpy as np

import matplotlib.dates as mdates
from matplotlib.ticker import AutoMinorLocator

fig, ax = plt.subplots(layout='constrained')
x = np.arange(0, 360, 1)
y = np.sin(2 * x * np.pi / 180)
ax.plot(x, y)
ax.set_xlabel('angle [degrees]')
ax.set_ylabel('signal')
ax.set_title('Sine wave')


def deg2rad(x):
    return x * np.pi / 180


def rad2deg(x):
    return x * 180 / np.pi


secax = ax.secondary_xaxis('top', functions=(deg2rad, rad2deg))
secax.set_xlabel('angle [rad]')
plt.show()

[링크 : https://matplotlib.org/stable/gallery/subplots_axes_and_figures/secondary_axis.html]

 

특이하게 배열로 된 값이 들어가는게 아닌, 함수를 통해서 1차축에 대해서 계산해서 2차축을 쓰는 듯?

Axes.secondary_xaxis(location, *, functions=None, **kwargs)
Axes.secondary_yaxis(location, *, functions=None, **kwargs)

functions2-tuple of func, or Transform with an inverse
If a 2-tuple of functions, the user specifies the transform function and its inverse. i.e. functions=(lambda x: 2 / x, lambda x: 2 / x) would be an reciprocal transform with a factor of 2. Both functions must accept numpy arrays as input.

The user can also directly supply a subclass of transforms.Transform so long as it has an inverse.

See Secondary Axis for examples of making these conversions.

[링크 : https://matplotlib.org/stable/api/_as_gen/matplotlib.axes.Axes.secondary_xaxis.html#matplotlib.axes.Axes.secondary_xaxis]

[링크 : https://matplotlib.org/stable/api/_as_gen/matplotlib.axes.Axes.secondary_yaxis.html#matplotlib.axes.Axes.secondary_yaxis]

'Programming > python(파이썬)' 카테고리의 다른 글

파이썬 가상환경  (0) 2024.01.09
pyplot legend picking  (0) 2023.10.05
pyplot  (0) 2023.10.04
python matplotlib 설치  (0) 2023.03.08
python openCV / PIL 포맷 변경  (0) 2022.04.12
Posted by 구차니

하나의 그래프에 여러개의 데이터를 한번에 그리기

import matplotlib.pyplot as plt
import numpy as np
  
# create data
x = [1,2,3,4,5]
y = [3,3,3,3,3]
  
# plot lines
plt.plot(x, y, label = "line 1", linestyle="-")
plt.plot(y, x, label = "line 2", linestyle="--")
plt.plot(x, np.sin(x), label = "curve 1", linestyle="-.")
plt.plot(x, np.cos(x), label = "curve 2", linestyle=":")
plt.legend()
plt.show()

[링크 : https://www.geeksforgeeks.org/plot-multiple-lines-in-matplotlib/]

 

'Programming > python(파이썬)' 카테고리의 다른 글

pyplot legend picking  (0) 2023.10.05
matplotlib  (0) 2023.10.04
python matplotlib 설치  (0) 2023.03.08
python openCV / PIL 포맷 변경  (0) 2022.04.12
파이썬 딕셔너리 변수 생성과 리턴 enumerate, zip  (0) 2022.04.12
Posted by 구차니

matplotlib을 이용하여 python 에서 그래프를 그리려고 하는데 그려지지 않아서 고생 -_-

그냥 설치하면 이상한(?) 에러가 발생하면서 중단되는데

나의 경우에는 jpeg 라이브러리 없다고 배쨰는 중. 그래서 libjpeg 등을 설치하고 Pillow 라는 python 패키지를 설치후

matplotlib을 설치하니 해결되었다.

 

sudo apt install libjpeg-dev zlib1g-dev
pip install Pillow

[링크 : https://stackoverflow.com/questions/44043906/the-headers-or-library-files-could-not-be-found-for-jpeg-installing-pillow-on]

pip3 install matplotlib

[링크 : https://www.zinnunkebi.com/python-modulenotfounderror-matplotlib/]

'Programming > python(파이썬)' 카테고리의 다른 글

matplotlib  (0) 2023.10.04
pyplot  (0) 2023.10.04
python openCV / PIL 포맷 변경  (0) 2022.04.12
파이썬 딕셔너리 변수 생성과 리턴 enumerate, zip  (0) 2022.04.12
python interactive mode  (0) 2022.03.15
Posted by 구차니

필요한 건 openCV로 받아 PIL로 변환하는거라 아래것만 테스트 해봄

import cv2
from PIL

opencv_image=cv2.imread(".\\learning_python.png")
color_coverted = cv2.cvtColor(opencv_image, cv2.COLOR_BGR2RGB)
pil_image=PIL.Image.fromarray(color_coverted)

[링크 : https://www.zinnunkebi.com/python-opencv-pil-convert/]

'Programming > python(파이썬)' 카테고리의 다른 글

pyplot  (0) 2023.10.04
python matplotlib 설치  (0) 2023.03.08
파이썬 딕셔너리 변수 생성과 리턴 enumerate, zip  (0) 2022.04.12
python interactive mode  (0) 2022.03.15
python3 opencv2 checker board  (0) 2022.03.14
Posted by 구차니

발견하게 된 생소한 문법은 아래와 같은데..

enumerate() 함수를 이용해 이름 목록을 열거하고 인덱스와 함께 

name(키) 와 outputs 라는 구조를 쌍으로 묶어 딕셔너리로 돌려준다.

return {name: outputs[i] for i, name in enumerate(self.output_names)}

 

def create_dict():
    ''' Function to return dict '''
    return {i:str(i) for i in range(10)}
numbers = create_dict()
print(numbers)
# {0: '0', 1: '1', 2: '2', 3: '3', 4: '4', 5: '5', 6: '6', 7: '7', 8: '8', 9: '9'}

[링크 : https://blog.finxter.com/python-return-dictionary-from-function/]

 

enumerate() 는 내용과 인덱스를 같이 돌려주고 start 키워드를 이용해 시작 인덱스를 0이 아닌 것으로 설정이 가능하다.

>>> for entry in enumerate(['A', 'B', 'C']):
...     print(entry)
...
(0, 'A')
(1, 'B')
(2, 'C')

[링크 : https://www.daleseo.com/python-enumerate/]

 

enumerate()와 유사하게 두개의 배열을 하나의 쌍으로 묶어주는 함수

>>> numbers = [1, 2, 3]
>>> letters = ["A", "B", "C"]
>>> for pair in zip(numbers, letters):
...     print(pair)
...
(1, 'A')
(2, 'B')
(3, 'C')

[링크 : https://www.daleseo.com/python-zip/]

'Programming > python(파이썬)' 카테고리의 다른 글

python matplotlib 설치  (0) 2023.03.08
python openCV / PIL 포맷 변경  (0) 2022.04.12
python interactive mode  (0) 2022.03.15
python3 opencv2 checker board  (0) 2022.03.14
pdb  (0) 2022.03.14
Posted by 구차니

별건 아니고 그냥

python 실행해서 뜨는 프롬프트에서 입력해서 실행하는 모드

 

[링크 : https://en.m.wikibooks.org/wiki/Python_Programming/Interactive_mode]

[링크 : https://stackabuse.com/python-programming-in-interactive-vs-script-mode/]

 

'Programming > python(파이썬)' 카테고리의 다른 글

python openCV / PIL 포맷 변경  (0) 2022.04.12
파이썬 딕셔너리 변수 생성과 리턴 enumerate, zip  (0) 2022.04.12
python3 opencv2 checker board  (0) 2022.03.14
pdb  (0) 2022.03.14
python debug (pdb)  (0) 2022.03.04
Posted by 구차니